akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
inline void upd(int &x, const int &y)
{
	x += y;
	if (x >= MOD)
		x -= MOD;
}
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
int sum[200005], arr[200005], app[200005], pre[200005], val[200005], n;
inline void modify(int pos, int x)
{
	for (; pos <= n; pos += pos & -pos)
		upd(sum[pos], x);
}
inline int query(int pos)
{
	int res = 0;
	for (; pos; pos -= pos & -pos)
		upd(res, sum[pos]);
	return res;
}
int main()
{
	// freopen("AGC023-E.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		app[arr[i]]++;
	}
	for (int i = n; i; i--)
		app[i] += app[i + 1];
	ll coef = 1, ans = 0;
	for (int i = 1; i <= n; i++)
	{
		app[i] -= n - i;
		if (app[i] <= 0)
		{
			puts("0");
			return 0;
		}
		if (app[i] == 1)
			pre[i] = i;
		else
		{
			pre[i] = pre[i - 1];
			val[i] = (ll)(app[i] - 1) * quick_pow(app[i], MOD - 2) % MOD;
			if (val[i - 1])
				val[i] = (ll)val[i] * val[i - 1] % MOD;
		}
		coef = coef * app[i] % MOD;
	}
	for (int i = 0; i < n; i++)
	{
		(ans += coef * (query(arr[i]) - query(pre[arr[i]])) % MOD * val[arr[i]]) %= MOD;
		modify(arr[i], quick_pow(val[arr[i]], MOD - 2));
	}
	memset(sum, 0, sizeof(sum));
	for (int i = 0; i < n; i++)
	{
		(ans += coef * (i - query(arr[i])) * 2) %= MOD;
		modify(arr[i], 1);
	}
	memset(sum, 0, sizeof(sum));
	for (int i = n - 1; i >= 0; i--)
	{
		if (val[arr[i]])
		{
			(ans -= coef * (query(arr[i] - 1) - query(pre[arr[i]])) % MOD * val[arr[i]]) %= MOD;
			modify(arr[i], quick_pow(val[arr[i]], MOD - 2));
		}
	}
	printf("%lld\n", (ans + MOD) * (MOD + 1) / 2 % MOD);
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int data[10000],c;
    c=0;
    while(1) {
        cin >> data[c];
        if (data[c]==0) break;
        c++;
    }
    for (int i=0;i<c;i++) {
        cout << "Case " << i+1 << ": " << data[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3020
#include <iostream>
#include <iomanip>
#include <vector>
 
int main() {
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }

    double ret = 0.0;
    for (auto a : A) {
        ret += 1.0 / a;
    }

    ret = 1.0 / ret;

    std::cout << std::setprecision(15);
    std::cout << ret << std::endl;            
}


Measured memory_bytes: 256
#include <stdio.h>
struct Node {
  int parent;
  int left;
  int right;
};
int n;
struct Node tree[100000];
int dipth[100000];
void getdip(int,int);
void printtree(int);
int main(){
  int i,id,j,num,p,l,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].parent=tree[i].left=tree[i].right=-1;
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&num);
    for(j=0;j<num;j++){
      scanf("%d",&p);
      if(j==0)tree[id].left=p;
      else tree[l].right=p;
      tree[p].parent=id;
      l=p;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)root=i;
  }
  getdip(root,0);
  for(i=0;i<n;i++)printtree(i);
  return 0;
}
void getdip(int r,int d){
  dipth[r]=d;
  if(tree[r].right!=-1)getdip(tree[r].right,d);
  if(tree[r].left!=-1)getdip(tree[r].left,d+1);
}
void printtree(int i){
  int m,j=0;
  printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,dipth[i]);
  if(tree[i].parent==-1)printf("root, [");
  else if(tree[i].left==-1)printf("leaf, [");
  else printf("internal node, [");
  m=tree[i].left;
  while(m!=-1){
    if(j!=0)printf(", ");
    printf("%d",m);
    m=tree[m].right;
    j++;
  }
  printf("]\n");
}



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

int main(void) {
  int N, count = 0, ai;
  bool fin = false;
  vector<int> button;
  cin >> N;
  vector<bool> check(N, false);
  for (int i = 0; i < N; i++) {
    cin >> ai;
    button.push_back(ai - 1);
  }
  for (int i = 0; !check[i]; i = button[i]) {
    check[i] = true;
    if (i == 1) {
      fin = true;
      break;
    }
    count++;
  }
  if (fin) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include<algorithm>

using namespace std;

int main() {
	int N, K;
	int d;
	int a[10100];
	int t = 0;
	int count = 0;
	cin >> N >> K;
	for (int i = 0; i < K;++i) {
		cin >> d;
		for (int j = 0; j < d; ++j) {
			cin >> a[t];
			++t;
		}
	}

	sort(a, a + t);
	for (int i = 0; i < t; ++i) {
		if (a[i] == a[i + 1]) {
			++count;
		}
	}
	cout << N - (t - count);
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long int
#define pi 3.14159265358979323846
using namespace std;
int main()
{
    ll t,n,ans;
    cin>>t>>n;
    ll a[n],sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>t)
    cout<<"-1"<<endl;
    else
    cout<<t-sum<<endl;
}

Measured memory_bytes: 3716
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      String S = sc.next();
      char c = S.charAt(0);

      S = "abcdefghijklmnopqrstuvwxyz";
      char[] a = new char[26];
      for (int i = 0; i < a.length; i++) {
         a[i] = S.charAt(i);
      }

      char cb = a[0];

      for (int i = 0; i < a.length-1; i++) {
         if(c == a[i]){
            cb = a[i+1];
         }
      }

      System.out.println(cb);

   }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 3e5 + 1;
//ll a[mxN];
set<ll> row[mxN], col[mxN];
set<array<ll, 2>> R, C;
ll n, m, q;
 
 
int main()
{
FIO
 
    cin >> n >> m >> q;
    For(q)
    {
        ll u, v;
        cin >> u >> v;
        row[u].in(v);
        col[v].in(u);
    }
    FOR(n) if(sz(row[i])) R.in({sz(row[i]), i});
    FOR(m) if(sz(col[i])) C.in({sz(col[i]), i});

    auto z = *R.rbegin();
    ll maxi1 = z[0];
    z = *C.rbegin();
    ll maxi2 = z[0];
    ll ans = maxi1 + maxi2 - 1;
    for(auto i = R.rbegin(); i != R.rend() && (*i)[0] == maxi1; i++)
    {
        vt<array<ll, 2>> vec;
        for(ll x: row[(*i)[1]])
        {
            array<ll, 2> temp = {sz(col[x]), x};
            C.erase(temp);
            vec.pb(temp);
        }
        if(!C.empty())
        {
            auto z = *C.rbegin();
            if(z[0] == maxi2)
            {
                ans = maxi1 + maxi2;
                break;
            }
        }
        for(auto x: vec) C.in(x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 97420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

vector<int> job[100005];

int main() {
  int n, m;
  cin >> n >> m;

  int a, b;
  rep(i, n) {
    cin >> a >> b;
    job[a - 1].push_back(b);
  }

  priority_queue<int> pq;
  int ans = 0;
  rep(i, m) {
    for (int x: job[i]) pq.push(x);
    if (pq.empty()) continue;
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 5632
n=int(input())
s=input()

tyo=0
tmax=0
for i in range(n):
  if s[i]==")":
    tyo+=1
    tmax=max(tmax,tyo)
  else:  # "("
    tyo-=1

lastkcnt=tmax+s.count("(")-s.count(")")
ans="("*tmax+s+")"*lastkcnt
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != t[i]) {
				cout << "No";
				return 0;
			}	
		}

		if (t.size() == s.size() + 1) {
			cout << "Yes";
		}

}

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

int main() {
  string S;
  cin >> S;

  rep(i, (int)S.size()) {
    S[i] = 'x';
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;


double calc(LL i){
    //while(i > 1999999999) i /= 10.;
    LL tmp = i;
    int s = 0;
    while(tmp != 0){
        s += tmp%10;
        tmp /= 10;
    }
    // cout << i << " " << (i+0.)/s << endl;
    return (i+0.)/s;
}

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


    LL K;
    cin >> K;
    double prev = 1;
    LL prev_i = 1;
    LL diff = 1;
    for(LL i=2; K>0; i+=diff){
        double now = calc(i);
        //cout << now << " ";
        if(now < prev){
            i -= diff*2;
            diff *= 10;
            i = i+diff;
            prev_i = i;
            prev = calc(prev_i);
        }else{
            cout << prev_i << endl;
            K--;
            prev_i = i;
            prev = now;
        }
    }
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct card
{
    char blue[20];
    char red[20];
}car[110];
int main()
{
  int n,m;
  char key[20];
  scanf("%d",&n);
   int i;
   for(i=0;i<n;i++)
    scanf("%s",car[i].blue);
    scanf("%d",&m);
   for(i=0;i<m;i++)
    scanf("%s",car[i].red);
    int cont=0,j,max=0;
   for(i=0;i<n;i++)
   {
       strcpy(key,car[i].blue);
       cont=0;
       for(j=0;j<n;j++)
       {
           if(strcmp(key,car[j].blue)==0)
           {
               cont++;
           }

       }

       for(j=0;j<m;j++)
       {
            if(strcmp(key,car[j].red)==0)
            cont--;
       }

       if(cont>=max)
      {
          max=cont;
      }


   }
      printf("%d ",max);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int someSums = 0;
			for(int i = 1; i <= N; i++){
					int sum = calcSum(i);
					if(sum >= A && sum <= B) someSums += i;	
			}
		System.out.println(someSums);	
	}
	private static int calcSum(int num){
    int sum = 0;
    while(num > 0){
      sum += num % 10;
      num /= 10;
    }
		return sum;
	}
}

Measured memory_bytes: 23124
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s<-getLine
  putStrLn $maybe "None" (:[]) $lookup False $zip (elemList ['a'..'z'] s) ['a'..'z']

elemList [] _ = []
elemList (x:xs) list  = elem x list : elemList xs list

Measured memory_bytes: 10144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int N = in.nextInt();
            for (int i = 0; i < N; i++) {
                long A = in.nextLong();
                long B = in.nextLong();

                long a = Math.min(A, B);
                long b = Math.max(A, B);
                long ans;

                if (a == b || a + 1 == b) {
                    ans = 2 * (a - 1);
                } else {
                    long c = (long) Math.sqrt(a * b);
                    if (c * c == a * b) c--;

                    if (c * (c + 1) < a * b) {
                        ans = 2 * c - 1;
                    } else {
                        ans = 2 * c - 2;
                    }
                }

                out.println(ans);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}



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

int main(){
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin>>n;
  cout << v.at(n-1) << endl;
}

Measured memory_bytes: 256
import math

n=int(input())

def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  if n % 2 == 0:
    # ２ではない偶数は素数ではない
    return False
  
  # nの半分まで計算する範囲を絞る
  m = math.floor(n / 2) + 1
  for p in range(3, m, 2): # 奇数だけ計算する
      if n % p == 0:
        return False
  return True

while isPrime(n)==False:
  n+=1

print(n)
  

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

using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    int sum=0;
    for(int i = 0;i<N;i++){
        sum +=i;
    }
    for(int i = 0;i<M;i++){
        sum +=i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double[][] point = new double[N][2];
    for (int i = 0; i < N; i++) {
      point[i][0] = sc.nextDouble();
      point[i][1] = sc.nextDouble();
    }
    sc.close();
    double distance = 0;
    int count = 0;
    for (int i = 0; i < N-1; i++) {
      for (int j = i+1; j < N; j++) {
        distance += Math.sqrt(Math.pow(point[i][0]-point[j][0], 2) + Math.pow(point[i][1]-point[j][1], 2));
        count += 1;
      }
    }

    double out = distance * ((double)(N-1)/count);
    System.out.println(out);
  }
}


Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;

int main() {
    int N;
    cin >> N;
    long a[N];
    map<long, long> mp;
    for (long i = 0; i < N; i ++) {
        cin >> a[i];
        mp[a[i]]++;
    }

    long long res = 0;
    for (auto s: mp) {
       if (s.second % 2 == 1){
         res++;
       }
    }

    cout << res << endl;
}

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

int n,m,l;
int a[110][110],b[110][110];
signed main(){
	cin>>n>>m>>l;
	rep(i,n){
		rep(j,m)cin>>a[i][j];
	}
	rep(i,m){
		rep(j,l)cin>>b[i][j];
	}
	rep(i,n){
		rep(j,l){
			int cnt=0;
			rep(k,m)cnt+=a[i][k]*b[k][j];
			cout<<cnt;
			if(j!=l-1)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3272
///#pragma GCC optimize("O3,unroll-loops")
///#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

const int N = 1000006;
ll inv[N], cnt[N], ans[N], sum[N], sq[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    double r;
    cin>>r;
    cout<<fixed<<setprecision(15)<<(2.0*PI*r)<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    ll N;
    input(N);
    set<ll> d;
    rep(i, 0, N)
    {
        ll di;
        input(di);
        d.insert(di);
    }

    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void){

    //入力
    int N, K;
    cin >> N;

    string S;
    cin >> S;

    cin >> K;

    //処理
    int i = 0;
    while(S[i] != '\0'){
        if(S[i] != S[K-1])   S[i] = '*';
        i++;
    }

    //出力
    cout << S << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main() {
	string v[] = {"a", "i", "u", "e", "o"};
	set<string> st(v, v + 5);
	string s;cin >> s;
	if (st.find(s) != st.end()) {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    
    cin>>n>>k;
        if(n%2==1 && (n+1)/k>=2) cout<<"YES"<<endl;
        else if(n%2==0 && (n/k)>=2)  cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NMAX 100

int compare(const void *a, const void *b);
int main(void)
{
  int i, j, n, res, ans = 0, red[NMAX][2], blue[NMAX][2];
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d %d", &red[i][0], &red[i][1]);
  for (i = 0; i < n; i++) scanf("%d %d", &blue[i][0], &blue[i][1]);
  qsort(blue, n, sizeof(int) * 2, compare);
  res = n;
  for (i = 0; i < n; i++) {
    int ridmax, rymax = -1;
    for (j = 0; j < res; j++) {
      if (blue[i][0] > red[j][0] && blue[i][1] > red[j][1] && rymax < red[j][1]) {
        rymax = red[j][1];
        ridmax = j;
      }
    }
    if (rymax != -1) {
      red[ridmax][0] = red[res-1][0];
      red[ridmax][1] = red[res-1][1];
      res--;
      ans++;
    }
  }
  printf("%d\n", ans);
}

int compare(const void *a, const void *b)
{
    int *ta = *(int(*)[2])a, *tb = *(int(*)[2])b;
    return ta[0] - tb[0];
}


Measured memory_bytes: 128
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

ans = "NO"
if a > b: a,b = a*(-1), b*(-1)
if a == b: ans = "YES"
elif a < b:
    if v > w and (b-a) <= (v-w)*t: ans = "YES"
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,c,p,ans;
int l[123456];
pair<int,int> wc[123456];
int main() {
	cin>>n>>m>>c;
	for(int i=1;i<=c;i++)cin>>l[i];
	for(int i=0;i<n;i++){
		cin>>wc[i].second>>wc[i].first;
		wc[i].first=1000-wc[i].first;
	}
	sort(wc,wc+n);
	for(int i=0;i<n&&p<m;i++){
		if(l[wc[i].second]){
			l[wc[i].second]--;p++;
			ans+=1000-wc[i].first;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4172
import sys
H, W = map(int, input().split())

S =[list(input()) for i in range(H)]
dy = [-1, 0, 1, 0]
dx = [0, 1, 0, -1]

for y in range(H):
    for x in range(W):
        if S[y][x] == "#":
            count = 0
            err_count = 0
            for i in range(4):
                    if not (0 <= y + dy[i] < H) or not(0 <= x + dx[i] < W):
                        err_count += 1
                        continue
                    else:
                        if S[y + dy[i]][x + dx[i]] == ".":
                            count += 1
            if count + err_count== 4:
                print("No")
                sys.exit()
#if 0 > y + dy  or y + dy >= H or 0 > x + dx or x +dx >= W:
print("Yes")

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

int main()
{
	int x,y;
	cin>>x>>y;
	if(4*x<y || 2*x>y || y%2==1)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
		
	return 0;
}

Measured memory_bytes: 3644
n=gets.to_i
s=gets.chomp.split("").map(&:to_s)
a=["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","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"]

(0..s.size-1).each do |x|
    print a[a.index(s[x])+n]
end

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

using namespace std;

int main(){
	int d, g, ans = 100000000;
	cin >> d >> g;
	vector<int> p(d), c(d);
	for(int i = 0; i < d; i++){
		cin >> p[i] >> c[i];
	}
	for(int i = 0; i < (1 << d); i++){
		int t = 0, q = -1, x = 0;
		for(int j = 0; j < d; j++){
			if(i & (1 << j)){
				t += (j + 1) * 100 * p[j] + c[j];
				x += p[j];
			}else{
				q = j;
			}
		}
		if(t < g){
			int po = (q + 1) * 100;
			if(g - t <= po * (p[q] - 1)){
				x += (g - t + po - 1) / po;
			}else{
				continue;
			}
		}
		ans = min(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(int(x) for x in input().split())

hp = 0
ans = 10**18

for i in range(100):
    for j in range(N):
        hp += (X[j] - i)*(X[j] - i)

    if ans > hp:
        ans = hp

    hp = 0

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  rep(i, 4) cout << s[i];
  cout << ' ';
  rep2(i, 4, 12) cout << s[i];
  cout << endl;
}

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

const int N = 1e5 + 100;

typedef long long LL;

int n, X;
LL pre_X[N];
LL pre_0[N];

struct Exam {
    int b, l, r;
    bool operator < (const Exam &e) {
        LL c0 = 1ll*X*r - 1ll*b*(r-l);
        LL c1 = 1ll*X*e.r - 1ll*e.b*(e.r-e.l);
        return c0 > c1;
    }
}E[N];

bool ok(LL days) {
    LL full = days/X, extra = days%X;
    if(full == n) return 1;
    for(int i = 1; i <= n; i++) {
        LL cur_X = 1ll*(X-E[i].b)*E[i].r;
        LL cur_0 = -1ll*E[i].b*E[i].l;
        LL D = 0;
        if(i <= full) D += pre_X[full+1] - cur_X + pre_0[full+2];
        else D += pre_X[full] + pre_0[full+1] - cur_0;
        if(extra <= E[i].b) D += 1ll*(extra-E[i].b)*E[i].l;
        else D += 1ll*(extra-E[i].b)*E[i].r;
        if(D >= 0) return 1;
    }
    return 0;
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> X;
    for(int i = 1; i <= n; i++) cin >> E[i].b >> E[i].l >> E[i].r;
    sort(E+1, E+n+1);
    for(int i = 1; i <= n; i++) {
        pre_X[i] = pre_X[i-1] + 1ll*(X-E[i].b)*E[i].r;
    }
    for(int i = n; i >= 1; i--) {
        pre_0[i] = pre_0[i+1] - 1ll*E[i].b*E[i].l;
    }
    LL lo = 0, hi = 1ll*n*X;
    while(hi > lo) {
        LL mid = (lo+hi)/2;
        if(ok(mid)) hi = mid;
        else lo = mid+1;
    }
    cout << lo << endl;
    return 0;
}


Measured memory_bytes: 2944
r = STDIN.gets.to_f
#
# r = 34.1201
#
#
#
 puts "#{ sprintf("%.6f",r*r*Math::PI) } #{sprintf("%.6f", r*2*Math::PI )}"
#





# r = 2
# res = r*r*Math::PI
#
# def s(v)
#   sprintf("%.6f", v)
# end
#
# p s(res)



Measured memory_bytes: 6872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input =new BufferedReader(new InputStreamReader(System.in));

        String[] inputs = input.readLine().split(" ");
        int a = Integer.parseInt(inputs[0]);
        int b = Integer.parseInt(inputs[1]);
        int c = Integer.parseInt(inputs[2]);

        if ((a+b) == c || (b+c) == a || (a+c) == b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 22996
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int[][] x = new int[n][d];
    int count = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < d; j++) {
        x[i][j] = sc.nextInt();
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        int num = 0;
        for (int k = 0; k < d; k++) {
          num += Math.pow(Math.abs(x[i][k] - x[j][k]), 2);
        }
        for (int k = 0; k <= num; k++) {
          if (k * k == num) {
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 36808
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use proconio::{fastout, input, marker::Bytes, marker::Chars, marker::Isize1, marker::Usize1};
#[allow(unused_imports)]
use std::cmp;
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);
    let mut b = sc.read_vec::<usize>(n);

    b.reverse();
    let mut lft = 0;
    let mut swapped = vec![false; n];
    for i in 0..n {
        if a[i] != b[i] {
            continue;
        }

        while lft < n && (b[i] == b[lft] || a[lft] == b[i] || swapped[lft]) {
            lft += 1;
        }
        if lft >= n {
            println!("No");
            return;
        }
        b.swap(i, lft);
        swapped[lft] = true;
        swapped[i] = true;
        lft += 1;
    }

    println!("Yes");
    for b in b.iter() {
        print!("{} ", *b);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 5044
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	char C;
	cin >> C;

	cout << static_cast<char>(C + 1);

	return 0;
}


Measured memory_bytes: 3644
#include "stdio.h"

int main(){
	int x;
	x=0;
	
	scanf("%d", &x);
	
	if(x<1200){
		printf("ABC\n");
		//printf("Smeke's current rating is less than 1200, thus the output should be ABC.\n");
	}
	else{
		printf("ARC\n");
		//printf("Smeke's current rating is not less than 1200, thus the output should be ARC.\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
N, M = map(int,input().split())
Sab = [list(map(int,input().split())) for i in range(N)]
Cab = [list(map(int,input().split())) for i in range(M)]

for i in range(N) :
    ansC = M+1
    anslen = 10**10
    for j in range(M) :
        Manh = abs(Sab[i][0] - Cab[j][0]) + abs(Sab[i][1] - Cab[j][1])
        if Manh < anslen :
            ansC = j+1
            anslen = Manh
    print(ansC)


Measured memory_bytes: 3064
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long a, b;
    scan(a, b);
    foreach (i; 0 .. 1001)
    {

        if (((i * 8) / 100 == a) && ((i * 10) / 100 == b))
        {
            writeln(i);
            return;
        }

    }

    writeln(-1);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3724
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	int a[200];
	
	int ind = 1;
	int max = 0;
	
	for(int i = 1; i <= N; i++){
		cin >> a[i];
		if(max < abs(a[i])){
			max = abs(a[i]);
			ind = i;
		}
	}
	
	if(a[ind] < 0){
		cout << 2 * N << endl;
		cout << ind << " " << 1 << endl;
		cout << ind << " " << 1 << endl;
		for(int i = N; i >= 2; i--){
			cout << 1 << " " << i << endl;
			cout << 1 << " " << 1 << endl;
		}
	}else if(a[ind] > 0){
		cout << 2 * N << endl;
		cout << ind << " " << N << endl;
		cout << ind << " " << N << endl;
		for(int i = 1; i < N; i++){
			cout << N << " " << i << endl;
			cout << N << " " << N << endl;
		}
	}else{
		cout << "0" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

int64_t H;
int32_t N;
int64_t A[114514];

int main(void) {
	int32_t i;
	int64_t s = 0;
	if (scanf("%" SCNd64 "%" SCNd32, &H, &N) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
		s += A[i];
	}
	puts(s >= H ? "Yes" : "No");
	return 0;
}


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

int countDigit(ll num) {
  int count = 0;

  while (num > 0) {
    num /= 10;
    count++;
  }
  return count;
}

bool isPrime(ll num) {
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }

  return true;
}

int main(void) {
  ll n;
  cin >> n;

  int ans = 10;
  double r = sqrt((double)n);
  if ((ll)r * r == n) {
    ans = countDigit((ll)r);
  } else if (isPrime(n)) {
    ans = countDigit(n);
  } else {
    for (ll i = (ll)r - 1; i <= n; ++i) {
      if (n % i == 0) {
        ans = countDigit(i);
        break;
      }
    }
  }

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define el endl
#define M 998244353 
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;

int32_t main() 
{ 
    int n;
    cin>>n;
    int a[n];
    FOR(i,0,n)
    cin>>a[i];
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    FOR(i,2,n)
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1];
    
    
    
} 

Measured memory_bytes: 1792
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x != None: x, y = x.left if key < x.key else x.right, x
    if y == None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result == None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 55688
#include<stdio.h>

int ru(int a){
	if(a==1)return 2;
	return ru(a-1)*2;
}

int main(){
	int n,m,i,j,l,ans=0;
	int k[100],s[100][100],p[100];
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&k[i]);
		for(j=0;j<k[i];j++)scanf("%d",&s[i][j]);
	}
	for(i=0;i<m;i++)scanf("%d",&p[i]);
	for(i=0;i<ru(n);i++){
		int icp=i;
		int ttmp[10]={0},c=0;
		while(icp>0){
			ttmp[c++]=icp%2;
			icp/=2;
		}
		int f=0;
		for(j=0;j<m;j++){
			int tr=0;
			for(l=0;l<k[j];l++){
				if(ttmp[s[j][l]-1]==1)tr++;
			}
			if(tr%2!=p[j]){
				f=1;
				break;
			}
		}
		if(f==0)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;


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

    ld a, b, h, m;
    cin >> a >> b >> h >> m;

    h = (h*60.0 + m)/12.0;
    ld x = (m-h);
    x*= acos(0)/15.0;
    ld sol = sqrt(a*a + b*b - 2.0*a*b*cos(x));
    cout << fixed << setprecision(9) << sol;

}


Measured memory_bytes: 4184
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int N=99;
int n;
char a[N+5];
bool pal(int l,int r){
	while(l<=r){
		if(a[l]!=a[r])return false;
		l++;r--;
	}
	return true;
}
int main(){
	cin>>a+1;
	n=strlen(a+1);
	puts(pal(1,n)&&pal(1,n-1>>1)&&pal(n+3>>1,n)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
lis = [2,5,5,4,5,6,3,7,6]
def new_val(num1,num2): # 123 , 4 -> 1234
    if num1<0:
        return -(10**10)
    if num1==0:
        return num2
    ret = (10**len(str(num2)))*num1 + num2
    return ret

dp = [[-(10**10) for i in range(1+n)] for j in range(1+m)]
for i in range(m):
    dp[i][0]=0

for i in range(m):
    num=a[i]
    honsu=lis[a[i]-1]
    for j in range(1+n):
        if j<honsu:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(new_val(dp[i+1][j-honsu] , num),dp[i][j])
print(dp[-1][-1])

Measured memory_bytes: 74016
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<int> H(N);
        rep(i, 0, N) cin >> H[i];

        int higest = -1;
        int ans = 0;
        for(int i = 0; i < N; ++i){
            chmax(higest, H[i]);
            if(higest == H[i]) ans++;
        }

        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	uf := NewUnionFind(N)
	groups := N
	for i := 0; i < M; i++ {
		A, B := ReadInt()-1, ReadInt()-1
		if !uf.Same(A, B) {
			groups--
			uf.Union(A, B)
		}
	}
	fmt.Println(groups - 1)
}

type UnionFind struct {
	parent []int
}

func NewUnionFind(n int) *UnionFind {
	uf := &UnionFind{
		parent: make([]int, n),
	}
	for i := 0; i < n; i++ {
		uf.parent[i] = i
	}
	return uf
}

func (uf *UnionFind) Find(a int) int {
	if a == uf.parent[a] {
		return a
	}
	uf.parent[a] = uf.Find(uf.parent[a])
	return uf.parent[a]
}

func (uf *UnionFind) Union(a, b int) {
	a = uf.Find(a)
	b = uf.Find(b)
	if a == b {
		return
	}
	uf.parent[a] = b
}

func (uf *UnionFind) Same(a, b int) bool {
	return uf.Find(a) == uf.Find(b)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 5996
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n;
	vector<string> ss(n);
	for(i=0;i<n;i++) {
		cin >> s;
		sort(s.begin(),s.end());
		ss[i] = s;
	}
	sort(ss.begin(), ss.end());
	/*for(i=0;i<n;i++) {
		cout << ss[i] << endl;
	}*/

	int idx = 0;
	int cnt = 1;
	vector<ll> aa(n);
	int ia = 0; 
	for(i=1;i<n;i++) {
		if (ss[idx] == ss[i]) {
			cnt++;
		} else {
			if (cnt>1) {
				aa[ia++] = cnt;
			}
			cnt = 1;
			idx = i;
		}
	}
	if (cnt>1) aa[ia++] = cnt;

	for(i=0;i<ia;i++) {
		//cout << aa[i] << endl;
		ans += aa[i]*(aa[i]-1)/2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int ansl=-1;
    int ansr=-1;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<"\n";
            return 0;
        }
        if(i<s.size()-2){
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<"\n";
            return 0;
        }
        }
    }
    cout<<ansl<<" "<<ansr<<"\n";
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<bool> d(10, true);
bool ok(int x)
{
    bool ret = true;
    while (x > 0)
    {
        if (!d[x % 10])
        {
            ret = false;
            break;
        }
        x /= 10;
    }
    return ret;
}

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

    int N, K;
    cin >> N >> K;
    int D;
    rep (i, K)
    {
        cin >> D;
        d[D] = false;
    }

    int ans = N;
    while (!ok(ans))
    {
        ++ans;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();
		String op = in.next();
		int b = in.nextInt();

		if (op.equals("+")) {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}

	}
}

Measured memory_bytes: 22612