akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
  
struct node 
{
  
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
  
typedef struct node* Node;
Node root;
  
Node treeSearch(Node x,int k) 
{
  if(x == NIL || k == x-> key)
    return x;
  if(k < x->key)
    return treeSearch(x->left,k);
  else return treeSearch(x->right,k );
}
  
void insert(int k) 
{
    
  Node y = NIL;
  Node x = root;
  Node z;
    
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
     
 while(x != NIL) 
   {
     y = x;
     if(z->key < x->key)
       x = x->left;
     
     else x = x->right;
   }
 z->parent = y;
 
 if(y == NIL)
   root = z;
 
 else if(z->key < y->key)
   y->left = z;
 
 else
   y->right = z;
 
}

void inorder(Node u) 
{
  
  if(u->left != NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)
    inorder(u->right);
}
  
void preorder(Node u) 
{
  printf(" %d",u->key);
  if(u->left != NIL)
    preorder(u->left);
  if(u->right != NIL)
    preorder(u->right);
}
  
int main(void) 
{
    
  int i,n,x;
  char c[5];
    
  scanf("%d",&n);
    
  for(i=0;i<n;i++) 
    {
      scanf("%s",c);
      if(c[0] == 'f') 
	{
	  scanf("%d",&x);
	  if(treeSearch(root,x) != NIL)
	    printf("yes\n");
	  else printf("no\n");
	}
      else if(c[0] == 'i') 
	{
	  scanf("%d",&x);
	  insert(x);
	}
      else if(c[0] == 'p') 
	{
	  if(root != NIL) 
	    inorder(root);
	  printf("\n");
	  if(root != NIL)
	    preorder(root);
	  printf("\n");
	  
	}
    }
  return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int x,y,a,b,c;
    cin >> x>>y>>a>>b>>c;
    int p[a],q[b],r[c];
    pair<int,int> pqr[a+b+c];
    for(int i=0;i<a;i++){
        cin >> p[i];
        pqr[i]=make_pair(p[i],1);
    }
    for(int i=0;i<b;i++){
        cin >> q[i];
        pqr[a+i]=make_pair(q[i],2);
    }
    for(int i=0;i<c;i++){
        cin >> r[i];
        pqr[a+b+i]=make_pair(r[i],3);
    }
    sort(p,p+a);
    reverse(p,p+a);
    sort(q,q+b);
    reverse(q,q+b);
    sort(r,r+c);
    reverse(r,r+c);
    sort(pqr,pqr+a+b+c);
    reverse(pqr,pqr+a+b+c);
    int inda=0,indb=0,indc=0;
    long long int res=0;
    int i=0;
    while(true){
        if(pqr[i].second==1){
            if(inda < x){
                inda++;
                res+=pqr[i].first;
            }
        }else if(pqr[i].second==2){
            if(indb < y){
                indb++;
                res+=pqr[i].first;
            }
        }else{
            res+=pqr[i].first;
            indc++;
        }
        // cout << res<<" "<<pqr[i].second<< endl;
        if(inda+indb+indc==x+y){
            break;
        }
        
        i++;

    }
    cout << res << endl;
    return 0;
}

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


int main()
{
    char s[1000090];
    scanf("%s",s);
    //cout<<s[2]<<s[3]<<endl;
    if((s[2] == s[3]) && (s[4]==s[5]))
           cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
S,K = input().split()
S = list(S)

ori = [0]
for i in range(len(S)-1,-1,-1):
    if S[i] == "0":
        ori.append(0)
    else:
        ori[-1] += 1

#print (ori)
N = len(ori)

K = int(K)
K = min(310,K)
mod = 998244353

dp = [[[0] * (K+1) for i in range(K+1)] for j in range(N+10)]

dp[-1][0][0] = 1


for i in range(N):

    #なにもしない
    for k in range(K+1):
        for x in range(k+1):
            dp[i][k][x] += dp[i-1][k][x]

    #1を追加する
    for x in range(K+1):

        nsum = 0

        for k in range(K+1):

            if x <= k:
                dp[i][k][x] += nsum
                dp[i][k][x] %= mod

            nsum += dp[i-1][k][x]

            if k-ori[i] >= 0:
                nsum -= dp[i-1][k-ori[i]][x]
            nsum %= mod

    #xを使用する

    for k in range(K+1):

        nsum = 0

        for x in range(k+1):

            dp[i][k][x] += nsum
            dp[i][k][x] %= mod

            if x >= 0:
                nsum += dp[i-1][k][x]

        nsum %= mod

    #print (dp[i])

ans = 0
for i in range(K+1):
    ans += dp[N-1][i][i]
    ans %= mod
print (ans)
            
    

Measured memory_bytes: 195420
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _024_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var ps = new int[n];
            for (int i = 0; i < n; i++)
            {
                ps[i] = ReadInt();
            }
            var lengthArray = new int[n];
            var indexDict = new Dictionary<int, int>();
            for(int i = n - 1; i >= 0; i--)
            {
                if (indexDict.ContainsKey(ps[i] + 1))
                {
                    lengthArray[i] = lengthArray[indexDict[ps[i] + 1]] + 1;
                }
                else
                {
                    lengthArray[i] = 1;
                }
                indexDict.Add(ps[i], i);
            }
            int max = 0;
            for(int i = 0; i < n; i++)
            {
                max = Math.Max(lengthArray[i], max);
            }
            Console.WriteLine(n - max);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 30684
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

auto factoring = [](i64 x){
 int sq = sqrt(x) + 1;
 vector<i64> ret;
 if(x == 1){
  return ret;
 }
 for(i64 i = 2; i < sq; ++i)
  while(x % i == 0){
   ret.emplace_back(i);
   x /= i;
  }
 if(x != 1)
  ret.emplace_back(x);
 return ret;
};


void solve(long long n){
    vector<i64> v = factoring(n);
    map<i64,int> m;
    for(auto x : v)
        ++m[x];
    int ans = 0;
    for(auto elm : m){
        int d = elm.second;
        for(int i = 1; i <= d; d -= i, ++i)
            ++ans;
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3792
from collections import deque
H,W = map(int,input().split())
s = []
for i in range(H):
    s.append(list(input()))

que = deque()
alr = [[float('inf') for i in range(W)] for j in range(H)]
if s[0][0] == '.':
    alr[0][0] = 0
else:
    alr[0][0] = 1
que.append((0,0))
while que:
    h,w = que.popleft()
    if s[h][w] == '#':
        flag = True
    else:
        flag = False

    if h < H-1:
        if s[h+1][w] == '.':
            if alr[h+1][w] > alr[h][w]:
                alr[h+1][w] = alr[h][w]
                que.append((h+1,w))
        else:
            if flag:
                if alr[h+1][w] > alr[h][w]:
                    alr[h+1][w] = alr[h][w]
                    que.append((h+1,w))
            else:
                if alr[h+1][w] > alr[h][w]+1:
                    alr[h+1][w] =alr[h][w]+1
                    que.append((h+1,w))            
    if w < W-1:
        if s[h][w+1] == '.':
            if alr[h][w+1] > alr[h][w]:
                alr[h][w+1] =alr[h][w]
                que.append((h,w+1))
        else:
            if flag:
                if alr[h][w+1] > alr[h][w]:
                    alr[h][w+1] =alr[h][w]
                    que.append((h,w+1))
            else:
                if alr[h][w+1] > alr[h][w]+1:
                    que.append((h,w+1))
                    alr[h][w+1] = alr[h][w] + 1
print(alr[-1][-1])

Measured memory_bytes: 46448
using System;

namespace AtCoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            int h = int.Parse(x[0]);
            int w = int.Parse(x[1]);

            string[] y = Console.ReadLine().Split(' ');
            int a = int.Parse(y[0]);
            int b = int.Parse(y[1]);

            Console.WriteLine((h - a) * (w - b));
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>

using namespace std;
int main(){
    string str;
    int ab[26]={};
    int i;
    while(getline(cin,str)){
        for(i=0;i<str.size();i++){
            if(str[i]>='a'&&str[i]<='z') ab[str[i]-'a']++;
            else if(str[i]>='A'&&str[i]<='Z') ab[str[i]-'A']++;
        }
    }
    for(i=0;i<26;i++){
        cout<<(char)('a'+i)<<" : "<<ab[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int L=S.length();
    int Yes_flag=1;
  
    for (int i=0;i<L;i++){
     if(i%2==0 && S[i]=='L') {
       Yes_flag=0;
       break;
     }
     else if(i%2==1 && S[i]=='R') {
       Yes_flag=0;
       break;
     }
    }
    if(Yes_flag==1)cout<<"Yes";
    else cout <<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    string s,t,ans;
    cin>>s>>t;
    int ls=s.size(),lt=t.size();
    vector<vector<int>> dp(ls+1,vector<int> (lt+1));
    repp(i,1,ls) {
        repp(j,1,lt) {
            if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }

    while(ls&&lt) {
        if(dp[ls][lt]==dp[ls][lt-1]) lt--;
        else if(dp[ls][lt]==dp[ls-1][lt]) ls--;
        else {ans+=s[ls-1];ls--;lt--;}
    }
    Repp(i,ans.size()-1,0) cout<<ans[i];
}

Measured memory_bytes: 35584
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int N = 1 * 1e5 + 10;
const ll inf = 1 * 1e9 + 10;

ll res;
ll a[N];

void solve() {
	ll  n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	std::vector<ll> dp(n, inf);
	dp[0] = 0;

	dp[1] = abs(a[1] - a[0]);

	for (int i = 2; i < n; ++i){
		for(auto j : {i - 1, i - 2}){
				dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
		}
	}
	cout << dp[n - 1];

}

int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
    return 0;
}

Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;

class NumTh{
	static long mod=1000000007; // 10e9 + 7
	static long GCD(long x, long y) {
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static int GCD(int x, int y) {
		return (int)GCD((long)x, (long)y);
	}
	static long LCM(long x, long y){
		return (x / GCD(x,y)) * y;
	}
	static int LCM(int x, int y) {
		return (int)LCM((long)x, (long)y);
	}
	// $a^x$ mod m
	static long pow(long a, long x){
		if(x == 1) return a;
		else if(x % 2 == 0) return pow((a * a), x / 2);
		return (a * pow((a * a), x / 2));
	}
	static boolean ip(long x) {
		if(x == 1) return false;
		for(long i = 2; i * i <= x; i++) if(x % i == 0) return false;
		return true;
	}
	static LinkedList<Long> fact(long n) {
		long tn = n;
		LinkedList<Long> factorize = new LinkedList<Long>();
		for(long i = 2; i <= tn; i++) {
			if(n == 1) break;
			if(ip(i)) {
				while(n % i == 0) {
					factorize.add(i);
					n /= i;
				}
			}
		}
		return factorize;
	}
}
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long P = sc.nextLong();
		HashMap<Long, Long> fact = new HashMap<Long, Long>();
		if(NumTh.ip(P)) {
			fact.put(P, (long) 1);
		}else {
			for(long i = 2; P != 1; i++) {
				if(P % i == 0) {
					long cnt = 0;
					while(P % i == 0) {
						cnt++;
						P /= i;
					}
					fact.put(i, cnt);
					if(NumTh.ip(P)) {
						fact.put(P, (long)1);
						break;
					}
				}
			}
		}
		long ans = 1;
		for(Entry<Long, Long> ent : fact.entrySet()) {
			if(ent.getValue() >= N) {
				long num = ent.getValue();
				ans *= NumTh.pow(ent.getKey(), num / N);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
import sys
mod = 10**9+7
N = int(sys.stdin.readline())
A = tuple(map(int, sys.stdin.readline().split()))
B = []
ans = 0
C = [0 for i in range(60)]
for i in A:
    for l in range(60):
        if ((i >> l) & 1) == 1:
            C[l] += 1
for i in range(60):
    t = C[i]
    ans = (ans + t*(N-t)*(2**i)) % mod
print(ans)

Measured memory_bytes: 123132
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;
const int MAX_N = 100005, MOD = 1000000007;
const i64 INF = 0x3f3f3f3f3f3f3f3fLL;

i64 f[MAX_N], g[MAX_N];
int mark1[MAX_N], mark2[MAX_N];

int N;
i64 A, B, S[MAX_N];

int main() {
  scanf("%d%lld%lld", &N, &A, &B);
  
  for (int i = 1; i <= N; ++i)
    scanf("%lld", &S[i]);

  int order = 0, rm1 = 0, rm2 = 0;
  i64 sum1 = 0, sum2 = 0;
  
  f[0] = g[0] = 1;

  int l1 = 0, l2 = 0;

  S[0] = -INF;
  for (int i = 2; i <= N; ++i) {
    ++order;
    while (l1 < i - 1 && S[i] - S[l1] >= A) {
      if (mark2[l1] >= rm2) sum1 = (sum1 + g[l1]) % MOD;
      l1++;
    }
    
    while (l2 < i - 1 && S[i] - S[l2] >= B) {
      if (mark1[l2] >= rm1) sum2 = (sum2 + f[l2]) % MOD;
      l2++;
    }
    
    f[i - 1] = (f[i - 1] + sum1) % MOD, mark1[i - 1] = order;
    g[i - 1] = (g[i - 1] + sum2) % MOD, mark2[i - 1] = order;
    if (S[i] - S[i - 1] < A) rm1 = order, sum2 = 0;
    if (S[i] - S[i - 1] < B) rm2 = order, sum1 = 0;
  }

  i64 res = 0;
  for (int i = 0; i < N; ++i) {
    if (mark1[i] >= rm1) res = (res + f[i]) % MOD;
    if (mark2[i] >= rm2) res = (res + g[i]) % MOD;
  }

  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 3328
a = []
b = []
for i in range(5):
    n = int(input())
    if n % 10 == 0:
        b.append(10)
    else:
        b.append(n % 10)
    while n % 10 != 0:
        n = n + 1
    a.append(n)

print(a[0] + a[1] + a[2] + a[3] + a[4] - 10 + min(b))

Measured memory_bytes: 3060
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int line = Integer.parseInt(br.readLine());
            
            if(line >= 1 && line <= 100){
	            line = line * line * line ;
	            System.out.println(line);
            }

        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

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

struct UnionFind {
    vector<int> par, rnk, cnt;
    UnionFind(int N) : par(N), rnk(N), cnt(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
            cnt[i] = 1;
        }
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y)
            return;
        if (rnk[x] < rnk[y])
            swap(x, y);
        if (rnk[x] == rnk[y])
            rnk[x]++;
        par[y] = x;
        cnt[x] += cnt[y];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int rcnt(int x) {
        return cnt[root(x)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    UnionFind uf(n);
    int ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if (j == i)
                continue;
            else
                uf.unite(a[j], b[j]);
        }
        if (uf.rcnt(0) < n)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoder.Program;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC133().SolveB(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
  class ABC133
  {
    public void SolveB(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var d = cin.ReadInt;
            var X = new int[n][];
            for (int i = 0; i < n; i++)
            {
                X[i] = cin.ReadIntArray(d);
            }
            int count = 0;
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    double distans = 0;
                    for (int k = 0; k < d; k++)
                    {
                        distans += Pow(Abs(X[i][k] - X[j][k]), 2);
                    }
                    distans = Sqrt(distans);
                    if ((int)distans == distans)
                    {
                        count++;
                    }
                }
            }
            WriteLine(count);
            ReadLine();
        }
  }
}


Measured memory_bytes: 13396
n,q = map(int,input().split())
rl = [0] * n
al = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a -1
for j in range(q):
    p,x = map(int,input().split())
    al[p-1] += x
for k in range(1,n):
    al[k] += al[rl[k]]
print(*al)


Measured memory_bytes: 25828
import numpy as np







def up(x):
	return x+10*(x%10!=0)-x%10



A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

l=[A,B,C,D,E]

m=np.array([i%10+10*(i%10==0) for i in l])
a=np.argmin(m)
out=0
for i in range(5):
	if(i==a):
		out+=l[i]
	else:
		out+=up(l[i])	

print(out)


Measured memory_bytes: 21416
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define for_(i,n) for(int i=0;i<n;++i)
const int mod= 1e9 +7;
const int inf=1e7;
int n;



void updateTreeNode(vector<int> & tree,int p, int value)  
{  
    // set value at position p 
    tree[p+n] = value; 
    p = p+n; 
      
    // move upward and update parents 
    for (int i=p; i > 1; i >>= 1) 
        tree[i>>1] = max(tree[i],tree[i^1]); 
} 
  
// function to get sum on interval [l, r) 
int query(vector<int> & tree,int l, int r)  
{  
    int res = -inf; 
      
    // loop to find the sum in the range 
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) 
    { 
        if (l&1)  
            res = max(res,tree[l++]); 
      
        if (r&1)  
            res = max(res,tree[--r]); 
    } 
      
    return res; 
} 


main()
{  
 cin>>n;
int h[n],a[n];
for_(i,n) cin>>h[i];
for_(i,n) cin>>a[i];
//int dp[n];
//vector<int> dp(n+1, inf);
/*
LIS::
dp[i] = length of increasing subsequence when it ends at arr[i]
		     	Recurrence relation:	dp[i] = max(1,  max(dp[j] +1));
 where j: 0,1… i-1 and arr[j]<arr[i]
Modify LIS to accomodate beauty value

*/
vector<int> tree(2*n+2, -inf);
//int ans=dp[0]= a[0];
//updateTreeNode(tree,h[0],dp[0]);                                  
int ans= a[0];
updateTreeNode(tree,h[0],a[0]);                                  

for(int i=1;i<n;++i)
{   
//dp[i] = max(a[i],query(tree,1,h[i])+a[i]);
int tmp=max(a[i],query(tree,1,h[i])+a[i]);
updateTreeNode(tree,h[i],tmp);
//ans=max(ans,dp[i]);
 ans=max(ans,tmp); 
}
cout<<ans<<endl;

    
}























/*
typedef struct structure{
    int x,y;
} pt;
pt p0;
bool cmp(pt a, pt b)
{
    return cw(p0,a,b);
}
bool cw(pt a, pt b, pt c){
    return ((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x))>=0
}



convex_hull(vector<pt>& points)
{
   // sort(points.begin(),points.end, cmp);// sorted according to y cordinate
    p0=points[0];
    sort(points.begin(),points.end, cmp);
    vector<pt> convexHull;
    stack<pt> temp;
    convexHull.push_back(points[0]);
    
    temp.push(points[0]);temp.push(points[1]);//temp.push(points[2]);
    pt top,top0;
    for(int it=2;it<points.size();++it)
    {   
        top=temp.top(); temp.pop(); top0=temp.top();
        pt next=points[it];
        if(cw(top0,top,next))
        {
            convexHull.push_back(top);
            temp.push(top);
            top0=top;
            top=next;
        }
        else
        {
          temp.push(next);  
        }
        
    }
    
}*/












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

using namespace std;
using ll = long long;


int main(){
  
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  
  if(A1+A2+A3>21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <limits>

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

	double output = 0.5;
	if (N % 2 != 0)
	{
		output = ((N - 1) / 2 + 1) / (double)N;
	}

	std::cout << output;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == S[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m >= 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv


def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n, k = map(int, input().split())

    fac, finv = initialize_cmb(n, mod)

    for i in range(1, k + 1):
        print(cmb(n - k + 1, i, fac, finv, mod) * cmb(k - 1, i - 1, fac, finv, mod) % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 42352
N = int(input()) - 1
rst = ''
for i in range(1, 10 ** 15):
    if N >= 26 ** i:
        N -= 26 ** i
        continue
    for j in range(i):
        rst += chr(ord('a') + N % 26)
        N //= 26
    print(rst[::-1])
    break

Measured memory_bytes: 9128
from collections import deque
d = deque([])
ans = input()
d.append(ans)
q = int(input())
rev = True # Trueなら後ろに # Falseなら前に
for i in range(q):
    Query = list(map(str,input().split()))
    if Query[0] == '2':
        if Query[1] == '1':
            if rev:
                d.append(Query[2])
            else:
                d.appendleft(Query[2])
        elif Query[1] == '2':
            if rev:
                d.appendleft(Query[2])
            else:
                d.append(Query[2])
    else:
        rev = rev^True
output = ""
while d:
    output += d.pop()
if rev:
    print(output)
else:
    print(output[::-1])


Measured memory_bytes: 5972
N = int(input())

p = list(map(float,input().split()))

DP = [[0]*(N+1) for i in range(N+1)]

DP[0][0] = 1

for i in range(N):
    for j in range(N+1):
        if j>0:
            DP[i+1][j] = DP[i][j]*(1-p[i]) + DP[i][j-1]*p[i]
        else:
            DP[i+1][j] = DP[i][j]*(1-p[i])

ans = 0

for i in range(N+1):
    if N-i<i:
        ans += DP[N][i]

print(ans)

Measured memory_bytes: 259720
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int mpe[100001],mpo[100001],mp[100001];
int main (){
      int n;
      cin>>n;
      int v[n];
      rep0(i,n) cin>>v[i];
      rep0(i,n){
            if(i%2==0){
                  mpe[v[i]]++;
            }
            else mpo[v[i]]++;
            mp[v[i]]++;
      }
      int maxe=0;
      int maxo=0;
      int maxx=0;
      rep0(i,n){
            if(i%2==0){
                  maxe=max(maxe,mpe[v[i]]);
            }
            else maxo=max(maxo,mpo[v[i]]);
            maxx=max(maxx,mp[v[i]]);
      }
      if(maxe+maxo>maxx){
            cout<<n-maxe-maxo<<endl;
      }
      else{
      sort(mpe,mpe+100001);
      reverse(mpe,mpe+100001);
      sort(mpo,mpo+100001);
      reverse(mpo,mpo+100001);
      cout<<n-max(mpe[0]+mpo[1],mpo[0]+mpe[1])<<endl;
      }


      return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, n, k;
    string s, t;
    ll ans;
    double dans;
    string sans;


    cin  >> a >> b;
    ll sum = 1;
    ans = 0;

    while(1){
        if(sum >= b) break;
        sum += a - 1;
        ans++;
    }

    std::cout << ans << endl; 
    // std::cout << sans << endl; 
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

void bfs(vector<vector<int>> a, vector<int> &d) {
	int n = a.size();
	queue<int> qu;
	qu.push(0);
	while (!qu.empty()) {
		int i = qu.front();
		qu.pop();
		REP(j, n) {
			if (d[j] == -1 && a[i][j]) {
				d[j] = d[i] + 1;
				qu.push(j);
			}
		}
	}
}

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

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n, 0));
	REP(i, n) {
		int u, k;
		cin >> u >> k;
		u--;
		REP(j, k) {
			int v;
			cin >> v;
			a[u][--v] = 1;
		}
	}
	vector<int> d(n, -1);
	d[0] = 0;
	bfs(a, d);
	REP(i, n) {
		cout << i + 1 << " " << d[i] << "\n";
	}

	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int bunshi = (int)(n+1)/2;
        System.out.println((double)bunshi/n);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include <iostream>
using namespace std;
int main(void){
    int n,sum;
    cin>>n>>sum;
    for(int i=0;i<n+1;i++){
        for(int j=0;j<n+1;j++){
            if(i+j>n) continue;
            if((i*10000+j*5000+(n-i-j)*1000)==sum){
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.collections.HashMap

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val dict = HashMap<String, Long>()
    for (i in 1..n) {
        val key = sc.next()
        dict.put(key, dict.getOrDefault(key, 0) + sc.nextLong())
    }
    for (pair in dict.toList().sortedWith(compareBy({it.first.length}, {it.first}))) {
        println("${pair.first} ${pair.second}")
    }
}


Measured memory_bytes: 49732
ABClist =  list(map(int, input().split()))
five = 0
seven = 0

for i in range(len(ABClist)):
  if ABClist[i] == 5:
    five += 1
  if ABClist[i] == 7:
    seven += 1
    
if five == 2 and seven == 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
    long int n,i,j,min = 10000000000000;
    scanf("%ld",&n);
    for(i = 1 ; i * i <= n ; i++)
    {
        if(n % i == 0)
        {
            if(min >= i + n / i - 2)
            {
                min = i + n / i - 2;
            }
        }
        
    }
    printf("%ld\n",min);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int ctoi(char);
int main(){
  int n;
  cin >> n;
  for(int I=0;I<n;I++){
    string st;
    cin >> st;
    int f=0;
    for(int j=0;j<2;j++){
      int r=-1;
      int l=-1;
      int t=j;
      for(int i=0;i<st.size();i++){
	//	cout << t;
	if(t==0){
	  r=ctoi(st[i]);
	  if(r==l||r==4){
	    f++;
	    break;
	  }
	}
	else{
	  l=ctoi(st[i]);
	  if(l==r||l==2){
	    f++;
	    break;
	  }
	}
	if(t==1)t=0;
	else t=1;
      }
    }
    if(f!=2)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;


}
int ctoi(char a){
  if(a=='U')return 1;
  if(a=='R')return 2;
  if(a=='D')return 3;
  if(a=='L')return 4;
}

    

Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////


int main(){
    int n; cin >> n;
    int cnt = 0;
    for(int i=1; i<=n; i++) {
        string s = to_string(i);
        if(s.size()%2 == 1) cnt++;
    }
    cout << cnt << endl;

    
    return 0;
}

// EOF



Measured memory_bytes: 256
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int a,b,c;
int main()
{
	re(a),re(b),re(c);
	for(int i=0;i<=10000;++i)
	{
		if((a&1) || (b&1) || (c&1))
		{
			printf("%d\n",i);
			return 0;
		}
		int aa=a>>1,bb=b>>1,cc=c>>1;
		a=bb+cc;b=aa+cc;c=aa+bb;
	}
	puts("-1");
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)
/*

*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		VI tb = {
			400,
			600,
			800,
			1000,
			1200,
			1400,
			1600,
			1800,
		};
		ll ans=0;
		REP(i, 8) {
			if(tb[i]<=N) ans=8-i;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <map>

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

constexpr int inf = 2e9;

using datum = std::pair<std::pair<int, int>, int>;
std::vector<datum> A;

std::vector<std::vector<int>> D;

int main(void){
    int n, Ma, Mb; scanf("%d%d%d", &n, &Ma, &Mb);
    A.resize(n);

    int x = 0, y = 0;
    REP(i, n){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        A[i].first = {a, b}; A[i].second = c;
        x += a; y += b;
    }

    D.resize(x+1, std::vector<int>(y+1, inf));
    D[0][0] = 0;
    REP(i, n){
        int a, b, c;
        std::tie(a, b) = A[i].first; c = A[i].second;
        for(int u = x; u >= 0; --u){
            for(int v = y; v >= 0; --v) if(D[u][v] != inf){
                if(D[u+a][v+b] > D[u][v] + c) D[u+a][v+b] = D[u][v] + c;
            }
        }
    }
    int res = inf;
    for(int X = Ma, Y = Mb; X <= x and Y <= y; X += Ma, Y += Mb )
                                        if(D[X][Y] < res) res = D[X][Y];

    if(res == inf) puts("-1");
    else printf("%d\n", res);
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{double a,b,x;
cin>>a>>b>>x;
unsigned long long int v=a*a*b;
if(x>v/2)
{double k=((2*x)/(a*a))-b;
double ang=atan((b-k)/a);
cout<<fixed<<setprecision(6)<<ang*180/M_PI;
}
else
{double k=((2*x)/(a*b));
double ang=atan(b/k);
cout<<fixed<<setprecision(8)<<ang*180/M_PI;
}
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N, M;
    ll A;
    ll sum = 0;

    cin >> N >> M;

    for(ll i = 0; i < M; i++){
        cin >> A;
        sum += A;
    }

    if(sum > N){
        cout << "-1" << endl;
    }else{
        cout << N - sum << endl;
    }

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll x, y, a, b, c, ans = 0, t;
  cin >> x >> y >> a >> b >> c;
  priority_queue<ll> p, q, r;
  rep(i, a) cin >> t, p.push(t);
  rep(i, b) cin >> t, q.push(t);
  rep(i, c) cin >> t, r.push(t);

  ll xi = x, yi = y;
  rep(i, x + y) {
    ll mx = 0, pp = 0, qq = 0, rr = 0;
    if (xi > 0 && p.size() > 0) pp = p.top();
    if (yi > 0 && q.size() > 0) qq = q.top();
    if (r.size() > 0) rr = r.top();

    mx = max({pp, qq, rr});
    ans += mx;
    if (mx == p.top())
      p.pop(), xi--;
    else if (mx == q.top())
      q.pop(), yi--;
    else
      r.pop();
  }

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


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++){
        	a[i]=sc.nextInt();
        }
        for(int i=n-1;i>=0;i--){
        	System.out.print(a[i]);
        	if(i==0){
        		break;
        	}
        	System.out.print(" ");
        }
        System.out.println();
    }
}


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

ll mod = 1'000'000'000 + 7;
int main(){
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    vector<ll> CT(2000+10,0);
    rep(i,N){
        int x; cin>>x;
        A[i]=x;
        CT[x]++;
    }

    // ブロックごと
    ll ans=0;
    ll bbsum=0;
    for(ll i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(A[i]>A[j]){
                bbsum++;
            }
        }
    }
    ll kk = (K*(K-1))/2%mod;
    ans += (bbsum * kk );
    ans %= mod;
    cerr << ans << endl;
    // ans /= 2;

    cerr << ans << endl;
    // 各ブロック
    ll bsum=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(A[i]>A[j]){
                bsum++;
            }
        }
        bsum %= mod;
    }
    bsum = (bsum * K)%mod;
    ans += bsum;
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>

using namespace std;

int main() {
	string O, E;//文字列型変数O,Eを宣言

	cin >> O;//Oの入力

	cin >> E;//Eの入力

	int cnt;//cntを宣言
	
	for (cnt = 0; cnt < E.size(); cnt++) {
		cout << O[cnt] << E[cnt];
	}

	if (O.size() != E.size()) {
		cout << O[cnt];
	}

	return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n, m;
    cin >> n >> m; //スイッチと電球
    vi b(m);
    rep(i, m)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int a;
            cin >> a;
            b[i] |= 1 << (a-1);
        }
    }
    vi p(m);
    rep(i, m) cin >> p[i];
    ll ans = 0;
    rep(i, 1 << n) {
        bool f = true;
        rep(j, m) {
            if(__builtin_popcount(b[j] & i) % 2 != p[j]) {
                f = false;
                break;
            }
        }
        if(f) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	//ループしてさらにそれがNに届かないといけないのか・・・無念
	int N, M;
	cin >> N >> M;

	vector<pair<pair<int, int>, ll>> E;

	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		E.pb(mp(mp(a, b), c));
	}

	ll kyori[1001];
	rep1(i, N) kyori[i] = -1e18;
	ll kotae1, kotae2;
	kyori[1] = 0;
	rep(i, 2 * N) {
		for (auto itr : E) {
			if (kyori[itr.first.first] != (ll)(-1e18)) {
				if (kyori[itr.first.second] < kyori[itr.first.first] + itr.second) {
					kyori[itr.first.second] = kyori[itr.first.first] + itr.second;
				}
			}
		}
		if (i == N - 1) kotae1 = kyori[N];
		if (i == 2 * N - 1) kotae2 = kyori[N];
	}

	if(kotae1 == kotae2) co(kotae1);
	else co("inf");

	Would you please return 0;
}

Measured memory_bytes: 384
from sys import stdin
N=(stdin.readline().rstrip())
N=list(N)
ans=""
for j in ["+","-"]:
    for k in ["+","-"]:
        for l in ["+","-"]:
            equ = N[0] + j + N[1] + k + N[2] + l + N[3]
            if eval(equ) == 7:
                ans = equ
print(ans+"=7")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int kosu=1;
		int max=sc.nextInt();
		for(int i=1; i<N; i++) {
			int tmp=sc.nextInt();
			if(max<=tmp) {
				kosu++;
				max=tmp;
			}
		}
		pl(kosu);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 23124