akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define f first
#define s second
 
typedef pair<int, int> P;
typedef map<string, P> Program;
 
Program prog;
vector<string> all;
vector<string> fav;
vector<string> normal;
bool watched[7][1800];
int ans;

int toMinute(string t){
  int ret = 0;
  if(t.size() == 3){
    ret += (t[0]-'0') * 60;
    ret += (t[1]-'0') * 10 + (t[2]-'0');
  }
  else if(t.size() == 4){
    int h =(t[0]-'0') * 10 + (t[1]-'0');
    ret += h * 60;
    ret += (t[2]-'0') * 10 + (t[3]-'0');
  }
  return ret;
}
 
bool watchFavAnime(){
  rep(i, fav.size()){
    P t = prog[fav[i]];
    for(int T = t.s ; T < t.s+30 ; T++){
      if(watched[t.f][T] == 1) return false;
      watched[t.f][T] = 1;
    }
    ans++;
  }
  return true;
}

void init(){
  prog.clear();
  fav.clear();
  all.clear();
  normal.clear();
  memset(watched, 0, sizeof(watched));
  ans = 0;
}

int main(){
  int n, p; 
  while(cin >> n, n){
    init();
    string name, tim;
    P t;
    rep(i, n){
      cin >> name >> t.f >> tim;
      int m = toMinute(tim);
      t.s = m;
      prog[name] = t;
      all.push_back(name);
    }
     
    cin >> p;
    rep(i, p){
      cin >> name;
      fav.push_back(name);
    }
    
    if(!watchFavAnime()){
      cout << "-1" << endl;
      continue;
    }
     
    rep(i, n){
      bool flag = true;
      rep(j, fav.size()){
	if(all[i] == fav[j]){
	  flag = false;
	  break;
	}
      }
      if(flag) normal.push_back(all[i]);
    }
    
    vector<P> nor;
    rep(i, normal.size()){
      nor.push_back(prog[normal[i]]);
    }
    
    sort(nor.begin(), nor.end());
    
    rep(i, nor.size()){
      int w = nor[i].f;
      int m = nor[i].s;
      bool f = true;
      for(int T = m ; T < m+30 ; T++){
	if(watched[w][T] == 1){
	  f = false;
	  break;
	}
      }
      if(f){
	for(int T = m ; T < m+30 ; T++){
	  watched[w][T] = 1;
	}
	ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  string S; cin>>S;
  string res;
  if(S.at(0)=='S')res = "Cloudy";
  else if(S.at(0)=='C')res = "Rainy";
  else res = "Sunny";
  cout<<res<<endl;
  return 0;
}

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

int main(){
    int N, W;
    cin >> N >> W;
    
    vector<int> v(N), w(N);
    vector<vector<int>> dp(N+1, vector<int>(W+1));

    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
        }
    }
    
    cout << dp[N][W] << endl;
    
    return 0;
}

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

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

  int N, A;
  cin >> N >> A;

  int ans = A;

  for (int i = 1; i < N; i++) {
    cin >> A;
    ans = __gcd(ans, A);
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;

ll n, MaxBen = 0LL;
vector<ll> dp(2e5 + 1, -1);
ll Maxval(ll st, vector<ll> &h, vector<ll> &a){
    ll val = a[st], maxIncr = 0LL;
    if(dp[st ] != -1LL)
        return dp[st];
    F(ll, i, 0, st - 1){
        if(h[i] <= h[st]){
            maxIncr = max(maxIncr, Maxval(i, h, a));
        }
    }
    val += maxIncr;
    dp[st] = val;
    MaxBen = max(MaxBen, val);
    return val;
}

ll Query(ll st, ll end, ll node, ll l, ll r, vector<ll> &Tree){
    if(st > end)
        return 0LL;
    if((r < st) || (end < l))
        return 0LL;
    if((l <= st) && (end <= r))
        return Tree[node];
    ll mid = (st + end) >> 1;
    return max( Query(st, mid, (node << 1), l, r, Tree), 
                Query(1LL + mid, end, (node << 1) + 1, l, r, Tree)); 
}

void update(ll st, ll end, ll node, ll indx, ll val, vector<ll> &Tree){
    if((indx < st) || (indx > end))
        return;
    if(st == end){
        Tree[node] = val;
        return;
    }
    ll mid = (st + end) >> 1;
    update(st, mid, (node << 1), indx, val, Tree);
    update(mid + 1LL, end, (node << 1) + 1, indx, val, Tree);
    Tree[node] = max(Tree[(node << 1)],
                     Tree[(node << 1) + 1]);
}

void solve()
{
    cin>>n;
    vector<ll> Height(n), Beauty(n), Tree((n << 2) + 1, 0);
    F(ll, i, 0, n - 1){
        cin>>Height[i];
    }
    F(ll, i, 0, n - 1){
        cin>>Beauty[i];
    }
    // RF(ll, i, n - 1, 0){
    //     Maxval(i, Height, Beauty);
    // }
    //We need to find the maximum value of dp 
    //in heights less than our height
    //For this we need that the heights are in increasing 
    //order ,so that we can query over a range easily and find the
    //maximum of them. For this we can use segment tree .For heights
    //That we don't wanna involve ,we can simply initialize them as 0
    F(ll, st, 0, n - 1){
        ll Maxincr = Query(0, n - 1, 1, 0, Height[st] - 2, Tree);
        dp[st] = Maxincr + Beauty[st];
        update(0, n - 1, 1, Height[st] - 1, dp[st], Tree);
        MaxBen = max(MaxBen, dp[st]);
    }
    cout<<MaxBen<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //freopen("Debug.txt", "w", stderr);
    #else
    #endif
    solve();
}


Measured memory_bytes: 14296
def solve(s):
    if len(s) % 2 == 1:
        return "No"
    for i, x in enumerate(s):
        if i % 2 == 0 and x != "h":
            return "No"
        if i % 2 == 1 and x != "i":
            return "No"
    return "Yes"


def main():
    s = input()
    res = solve(s)
    print(res)


def test():
    assert solve("hihi") == "Yes"
    assert solve("hi") == "Yes"
    assert solve("ha") == "No"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Q();
        }

        static void Q()
        {
            var S = Read();
            var a = int.Parse(S.Slice(0, 2));
            var b = int.Parse(S.Slice(2));

            var aIsMonth = 1 <= a && a <= 12;
            var bIsMonth = 1 <= b && b <= 12;
            var aIsYear = 0 <= a && a <= 99;
            var bIsYear = 0 <= b && b <= 99;
            if (aIsMonth && bIsMonth && aIsYear && bIsYear)
            {
                Println("AMBIGUOUS");
                return;
            }
            else if (aIsMonth && bIsYear)
            {
                Println("MMYY");
                return;
            }
            else if (bIsMonth && aIsYear)
            {
                Println("YYMM");
                return;
            }
            else
            {
                Println("NA");
            }
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include<algorithm>
#include<vector>
#include <unordered_map>
#include <cstdint>
#include <cstring>
#include <math.h>

using namespace std;
int main(){
    
    int n;
    int a[1000000];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int a_i,a_j;
    a_i=a[n-1];
    int min_idx=0;
    double cost;
    double min_cost=10000000000;
    for(int i=0;i<n-1;i++){
        cost=sqrt((double(a_i)/2-a[i])*(double(a_i/2)-a[i]));
        if(cost<min_cost){
            min_cost=cost;
            min_idx=i;
        }
    }
    cout<<a_i<<" "<<a[min_idx]<<endl;

}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int N;
	int dp[1001][7];
	int a[1001];
	char ch;   //I O J
	int mask[3]={1,2,4},haisu[3]={0,1,2};
	int i,j,k;
	cin>>N;
	
	for(i=1;i<=N;i++){
		for(j=1;j<=7;j++){
			dp[i][j]=0;
		}
	}
	fill(a,a+N,0);
	
	for(i=1;i<=N;i++){
		cin>>ch;
		if(ch=='J'){
			a[i]=a[i]|haisu[2];
		}
		else if(ch=='O'){
			a[i]=a[i]|haisu[1];
		}
		else{
			a[i]=a[i]|haisu[0];
		}
	}
	
	switch(a[1]){
		case 0:
		dp[1][5]=1;
		dp[1][7]=1;
		break;
		case 1:
		dp[1][6]=1;
		dp[1][7]=1;
		break;
		case 2:
		dp[1][4]=1;
		dp[1][5]=1;
		dp[1][6]=1;
		dp[1][7]=1;
		break;
	}
	
	/*for(i=1;i<=7;i++){
		cout<<dp[1][i]<<endl;
	}*/
	
	/*for(i=1;i<=N;i++){
		cout<<" a[i]= "<<a[i]<<endl;
	}*/
	
	for(i=1;i<=N-1;i++){
		for(j=1;j<=7;j++){
			for(k=1;k<=7;k++){
			//	cout<<"i="<<i<<" a[i]= "<<a[i]<<endl;;
 				if(((j&k)!=0)&&((k&mask[a[i+1]])!=0)){
					dp[i+1][k]+=dp[i][j];
					dp[i+1][k]=dp[i+1][k]%10007;
				}
			}
		}
	}
	
	/*for(i=1;i<=N;i++){
		for(j=1;j<=7;j++){	
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int sum=0;
	for(i=1;i<=7;i++){
		//cout<<dp[N][i]<<endl;
		sum+=dp[N][i]%10007;
		
		
	}
	
	cout<<sum%10007<<endl;
	
	return 0;
}
	


Measured memory_bytes: 3120
module Main where

import Data.Functor

main :: IO ()
main = do
  {[x, y] <- getInts
  ; if x == 0 && y == 0 then done
    else do
      {  case compare x y of
          LT -> putInts [x,y]
          GT -> putInts [y,x]
          EQ -> putInts [x,y]
      ; main
      }
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), r = fs.nextInt();
		int ans = r;
		if(n<10) {
			ans += (100*(10-n));
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   string s ;
   cin>>s ;
   if(s=="ABC") cout<<"ARC" ;
   else cout<<"ABC" ;


}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >> s;

	reverse(all(s));
	s += "00";
	int m=sz(s);
	const ll INF = 1LL<<55;
	VL dp = {0, INF};
	rep(i, m){
		VL np(2, INF);
		rep(j ,2){
			int x = s[i] -'0' + j;
			rep(d, 10){
				int c = d - x;
				if(c < 0) c +=10;  
				np[d < x] =  min(np[d < x] , dp[j] + c + d);
			}
		}
		swap(np, dp);
	}
	
	cout << dp[0] <<"\n";
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    a += b;
    cout << (a>=24 ? a-24 : a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int main(){
    while(true){
	int N,M;
	int r,q;
	cin >> N >> M;
	if(N == 0 && M == 0) break;
	int t[1001],n[1001],m[1001],s[1001];
	int ts[51],te[51],tm[51];
	cin >> r;
	REP(i,r){
	    cin >> t[i] >> n[i] >> m[i] >> s[i];
	}
	cin >> q;
	REP(i,q){
	    cin >> ts[i] >> te[i] >> tm[i];
	    int time = ts[i];
	    int c = 0;
	    int ans = 0;
	    for(int j=0; t[j] <= te[i] && j<r;j++){
		if(tm[i] == m[j]){
		    if(t[j] >= ts[i] && c > 0){
			ans += t[j] - time;
// 			printf("s = %d e = %d\n",time,t[j]);
		    }
		    c += s[j] == 1 ? 1 : -1;
		    time = max(ts[i],t[j]);
		}
	    }
	    if(c > 0) ans += te[i]-time;
	    cout << ans << endl;
	}
    }

    return 0;
}

Measured memory_bytes: 1172
cost = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

''' 再帰が深すぎて, 再起不能
def solve(yoshida, possible, dp):
    if(yoshida == 0):
        dp[0] = 0
    elif(dp[yoshida] == -1):
        for x in possible:
            if(yoshida >= cost[x]):
                idx = yoshida - cost[x]
                solve(idx, possible, dp)
                a = (dp[idx]) * 10 + x
                dp[yoshida] = max(dp[yoshida], a)
'''

def solve(yoshida, possible, dp):
    dp[0] = 0
    for i in range(n):
        a = 10 * dp[i]
        for x in possible:
            dp[i + cost[x]] = max(dp[i + cost[x]], a + x)
if __name__ == '__main__':
    n, m = map(int, input().split())
    lst = list(map(int, input().split(" ")))
    DP = [-1] * (n + 10)
    solve(n, lst, DP)
    '''
    for i in range(n + 1):
        print("{} : {}".format(i, DP[i]))
    '''
    print(DP[n])


Measured memory_bytes: 14572
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max({(N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D,
                 (N - 1) / E}) +
                5
         << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
std::cout << x/3 << '\n';
}


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

using namespace std;

long long cnt[2020], md[2][2020], tmp[2020];
int pr, cur;
const int MOD = 2019;
string s;

long long ans = 0;

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

	getline(cin, s);

	int idNow, idNxt;
	for(int i = 0; i < (int) s.size(); i++){
		idNow = i % 2; idNxt = 1 - idNow;

		int shift = s[i] - '0';

		md[idNow][0]++;

		for(int k = 0; k < MOD; k++) tmp[(k + shift) % MOD] = md[idNow][k];

		ans += tmp[0];

		for(int k = 0; k < MOD; k++){
			md[idNxt][(k * 10) % MOD] += tmp[k];
			md[idNow][k] = 0;
		}
	}

	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 3796
#include<stdio.h>
int m[]={5,1,2,4,1,3,1,0,0,2,3,2,2,4,5,1,4,0,4,3,3,5,0,5},a,b,c,d,r;char s[99];int main(){	for(s[87]=1,s[78]=4,s[69]=3,s[83]=2;~scanf("%s",s);*s<60?printf(r?"%d\n":0,r),a=c=0,b=r=1:(d=s[*s],d?d=d+c&3,a=m[4*a+d],b=m[4*b+d]:c+=*s-76?1:3,r+=a%3?b%3?(b+6-a)%6<3?2:5:3+!b:a?6:1));}

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

int main(){
  int N, K, A, B, C;
  cin >> A >> B >> C;
/*
  vector<char> S(N);
  for(int i = 0; i < N; i++)
    cin >> S.at(i);
*/
  if(A+B>=C) cout << B+C << endl;
  else cout << B*2+A+1<< endl;
}

Measured memory_bytes: 256
import           Control.Monad
import           Data.Array
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe
import           Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  n <- read <$> getLine
  print $ solve n

solve :: Int -> Int
solve n
  | odd n = 0
  | otherwise = how (n `div` 2)

how 0 = 0
how n = m + how m
  where
    m = n `div` 5


Measured memory_bytes: 508
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])
    K = int(inputs[1])

    if len(S) == 1:
        return int(S[0])

    for i, c in enumerate(S):
        if c == '1' and K == i + 1:
            return 1
        elif c != '1':
            return int(c)

    # count = 0
    # for i, c in enumerate(S):
    #     print(int(c) ** (49 * (10**14))
    #     # count += int(c) ** (49 * (10**14))
    #     # if count > K:
    #     #     return S[i-1]
    # return c


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 3316
import sys
input = sys.stdin.readline

K=int(input())
X,Y=map(int,input().split())

if K%2==0 and (X+Y)%2==1:
    print(-1)
    sys.exit()

ANS=[]
NOWX=0
NOWY=0

def dis(NOWX,NOWY,X,Y):
    return abs(NOWX-X)+abs(NOWY-Y)

def app():
    ANS.append((NOWX,NOWY))

if dis(NOWX,NOWY,X,Y)<K and dis(NOWX,NOWY,X,Y)%2==1:
    if X>0:
        NOWX-=K
        app()
    elif X<0:
        NOWX+=K
        app()
    elif Y>0:
        NOWY-=K
        app()
    elif Y<0:
        NOWY+=K
        app()
        

while dis(NOWX,NOWY,X,Y)>2*K:
    if X-NOWX>K:
        NOWX+=K
        app()
    elif NOWX-X>K:
        NOWX-=K
        app()
    elif Y-NOWY>K:
        NOWY+=K
        app()
    elif NOWY-Y>K:
        NOWY-=K
        app()



if dis(NOWX,NOWY,X,Y)!=K and dis(NOWX,NOWY,X,Y)%2==1:
    if X-NOWX>0:
        NOWX+=K
        app()
    elif NOWX-X>0:
        NOWX-=K
        app()
    elif Y-NOWY>0:
        NOWY+=K
        app()
    elif NOWY-Y>0:
        NOWY-=K
        app()



if dis(NOWX,NOWY,X,Y)==K:
    ANS.append((X,Y))

else:
    t=dis(NOWX,NOWY,X,Y)
    u=(K*2-t)//2

    if abs(NOWY-Y)<=abs(NOWX-X):

        if X<NOWX and Y>=NOWY:
                ANS.append((NOWX-(K-u),NOWY-u))
                ANS.append((X,Y))
        elif X<NOWX and Y<=NOWY:
                ANS.append((NOWX-(K-u),NOWY+u))
                ANS.append((X,Y))
                
        elif X>NOWX and Y>=NOWY:
                ANS.append((NOWX+(K-u),NOWY-u))
                ANS.append((X,Y))
        elif X>NOWX and Y<=NOWY:
                ANS.append((NOWX+(K-u),NOWY+u))
                ANS.append((X,Y))

    else:
        if X<=NOWX and Y>NOWY:
                ANS.append((NOWX+u,NOWY+(K-u)))
                ANS.append((X,Y))
        elif X<=NOWX and Y<NOWY:
                ANS.append((NOWX+u,NOWY-(K-u)))
                ANS.append((X,Y))
                
        elif X>=NOWX and Y>NOWY:
                ANS.append((NOWX-u,NOWY+(K-u)))
                ANS.append((X,Y))
        elif X>=NOWX and Y<NOWY:
                ANS.append((NOWX-u,NOWY-(K-u)))
                ANS.append((X,Y))
        
            
print(len(ANS))
for x,y in ANS:
    print(x,y)
        
        

    
    


Measured memory_bytes: 26040
#include<stdio.h>

int main(void)
{
   int a,b,s,i;

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

   s=0;
   for(i=0;i<2;i++){
      if(a>b){
      s=s+a; a=a-1;
      }
      else if(b>a){
      s=s+b; b=b-1;
      }
      else if(a=b){
      s=s+a; a=a-1;
      }
   }

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

   return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int arr[n-1],freq[n]={0};
  for(i=1;i<n;i++)
  {
    cin>>arr[i];
    freq[arr[i]-1]++;
  }
  for(i=0;i<n;i++)
    cout<<freq[i]<<endl;
  return 0;
}


Measured memory_bytes: 5184
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];
  int maxK = N * (N + 1) / 2;
  vector<int64_t> B;
  rep(i, N) {
    int64_t sum = 0;
    for (int j = i; j < N; ++j) {
      sum += A[j];
      B.emplace_back(sum);
    }
  }

  int64_t answer = 0;
  for (int i = 39; i >= 0; --i) {
    int count = 0;
    rep(j, maxK) {
      if ((B[j] & answer) == answer && (B[j] & (1LL << i))) ++count;
    }
    if (K <= count) answer |= (1LL << i);
  }
  cout << answer << endl;
  return 0;
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 3012, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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 pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

ll dp[N][N];

int main() {
    ios;
    ll n , s;
    cin >> n >> s;
    ll A = 0;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i ++) {
        dp[i][0] ++;
        ll x;
        cin >> x;
        for(int j = s; j >= x; j --) {
            dp[i][j] += dp[i-1][j-x];
            dp[i][j] %= mod2;
        }
        A += dp[i][s] * (n-i+1);
        A %= mod2;

        for(int j = 0; j <= s; j ++) {
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= mod2;
        }
    }

    cout << A;
    return 0;
}
/*
6 5
4 1 3 2 5 1
*/


Measured memory_bytes: 70912
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    char s[200010];
    char t[200010];
    cin >> s >> t;
    int counter=0;
    for(int i=0;i<strlen(s);i++){
        if(s[i]!=t[i]) counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3976
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

signed main() {
    int N, K; cin >> N >> K;
    int ans = 0;
    for(int b=K+1; b<=N; b++) {
        int d = (b - 1) - K + 1;
        int range = N / b;
        int val = d * range;
        val += max(0LL, N - (b*range + max(1LL, K)) + 1);
        // printf("b = %lld, d = %lld, range = %lld, val = %lld\n", b, d, range, val);
        ans += val;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // https://atcoder.jp/contests/abc147/submissions/8921445
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve_A(){
    input!(
        K : i32,
        X : i32,
    );
    println!("{}", if K * 500 >= X{ "Yes" } else { "No" });
}

fn main() {
    solve_A();
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k,x,y;cin>>n>>k>>x>>y;

  int t = min(k,n)*x;
  t += max(n-k, 0)*y;
  cout<<t<<endl;

  return 0;
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N; cin >> N;
    VI A(N), B(N);
    REP(i,N)
    {
        cin >> A[i];B[i] = A[i];
    }
    RSORT(B);
    int max = B[0];
    int second = B[1];

    REP(i,N)
    {
        if (A[i] == max) cout << second << endl;
        else cout << max << endl;
    }
    return 0;
}



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

namespace CSharpSample01
{

    class Program
    {

        

        static void Main(string[] args)
        {

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if(n == 0)
                {
                    break;
                }

                int max_point = 0;
                int min_point = 10000;
                int[] point_ary = new int[n];

                for (int i = 0; i < n; i++)
                {
                    int point = int.Parse(Console.ReadLine());

                    point_ary[i] = point;

                    if (point > max_point)
                    {
                        max_point = point;
                    }
                    if (point < min_point)
                    {
                        min_point = point;
                    }

                }

                
                int sum_point = 0;
                int result_point = 0;
                bool max_falg = false;
                bool min_falg = false;

                for (int i = 0; i < n; i++)
                {
                    int point = point_ary[i];

                    if(point == max_point && !max_falg)
                    {
                        max_falg = true;
                        continue;
                    }
                    else if(point == min_point && !min_falg)
                    {
                        min_falg = true;
                        continue;
                    }
                    else
                    {                        
                        sum_point += point;
                    }
                }
                
                result_point = sum_point / (n - 2);

                Console.WriteLine(result_point);

            }

        }
    }
}


Measured memory_bytes: 13852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m, l;
  cin >> n >> m >> l;

  vector<vector<int> > d(n, vector<int>(n, inf));
  rep(i, n) d[i][i] = 0;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = d[b][a] = c;
  }
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);

  vector<vector<int> > d2(n, vector<int>(n, inf));
  rep(i, n) rep(j, n) if (d[i][j] <= l) d2[i][j] = 1;
  rep(k, n) rep(i, n) rep(j, n) chmin(d2[i][j], d2[i][k] + d2[k][j]);

  int Q;
  cin >> Q;
  while (Q--) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    cout << (d2[s][t] == inf ? -1 : d2[s][t] - 1) << endl;
  }
}


Measured memory_bytes: 4004
/*
 *  Created on: 2 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ll a, b, n; cin >> a >> b >> n;
    ll ans = 0;
    if (n < b)
    {
        ans = (a * n) / b;
    }
    else
    {
        n = b - 1;
        ans = (a * n) / b;
    }
    cout << ans;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main()
{
long long a,b,c,i,N;
a=2;
b=1;
cin >> N;
N = N+1;
if(N>=3)
{
for(i=2; i<N; i=i+1)
{
c=b;
b=a+b;
a=c;
}
}
else
{
b = N-1;
}
printf ("%lld",b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

template< typename T, typename E >
struct SegmentTree{
	using F = function< T(T, T) >;
	using G = function< T(T, E) >;
	int sz;
	vector<T> dat;
	F f;
	G g;
	T t1;
	SegmentTree(int n, F f, G g, T t1) : f(f), g(g), t1(t1) {
		sz = 1;
		while(sz < n) sz *= 2;
		dat.clear();
		dat.resize(2 * sz - 1, t1);
	}
	void set(int k, T x) { dat[k + sz - 1] = x; }
	void build() {
		for(int k = sz - 2; k >= 0; k--) {
			dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	void update(int k, E x) {
		k += sz - 1;
		dat[k] = g(dat[k], x);
		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	T query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return t1;
		if(a <= l && r <= b) return dat[k];
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
	T query(int a, int b){ return query(a, b, 0, 0, sz); }
	T operator[](int k) { return dat[k + sz - 1]; }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n), a(n);
    rep(i, 0, n){
        cin >> h[i]; h[i]--;
    }
    rep(i, 0, n) cin >> a[i];
    SegmentTree<int, int> seg(n, 
		[](int a, int b){ return max(a, b); }, 
		[](int a, int b){ return b; }, 
		0);
    rep(i, 0, n){
        int tmp = seg.query(0, h[i]);
        seg.update(h[i], tmp + a[i]);
    }
    cout << seg.query(0, n) << endl;
}

Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <cctype>
#include <algorithm>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  string s; int n;  
  while(2893928){
    cin >> s >> n;
    if(s == "-") break;
    rep(i,n){
      int j;
      cin >> j;
      string l,r;
      l = s.substr(0,j);
      r = s.substr(j);
      s = r+l;
    }
    cout << s << endl;
  }
}



Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    
    vector<ll> a(n);
    for(ll i = 0; i<n; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    
    for(ll i = 0; i<n; i++){
        if(a[i]!=a[i+1]){
            continue;
        }
        else {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}
    
    



Measured memory_bytes: 1792
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<iostream>
using namespace std;
const int maxm=1e5+7;
typedef long long ll;
int n,l,r,ans;
int a[2*maxm];
bool big(int i,int j,int k)
{
   if(a[i]>=k&&a[j]>=k)
   return 1;
   else return 0;	
}
bool small(int i,int j,int k)
{
   if(a[i]<k&&a[j]<k)
   return 1;
   else return 0;	
}
bool check(int x)
{
  for(int i=0;i<n-1;i++)
  {
     if(big(n+i,n+i+1,x)||big(n-i,n-i-1,x)) return 1;
     if(small(n+i,n+i+1,x)||small(n-i,n-i-1,x)) return 0;
  }
  return big(1,1,x);
}
int main()
{
 scanf("%d",&n);
 for(int i=1;i<=2*n-1;i++)
 {
    scanf("%d",&a[i]);	
 }
 l=1,r=2*n-1;
 while(l<=r)
 {
    int mid=(l+r)>>1;
	if(check(mid))
	{
	   ans=mid;
	   l=mid+1;	
	}
	else r=mid-1;
 }
 printf("%d\n",ans);
 return 0;	
}

Measured memory_bytes: 1024
program abc076
    use,intrinsic :: iso_fortran_env
    implicit none
    character(50):: s,t
    character(50):: pred_s, ans
    integer(int32):: sn,tn,i,j
    logical:: contain

    read*, s
    read*, t
    sn = len_trim(s)
    tn = len_trim(t)
    ans = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
    do i=1, (sn-tn+1)
        contain = .true.
        do j=1,tn
            if (s(i+j-1:i+j-1) == '?') cycle
            if (s(i+j-1:i+j-1) /= t(j:j)) contain = .false.
        end do
        if (.not. contain) cycle
        pred_s = s(1:i-1) // trim(t(:)) // s(i+tn:sn)
        do j=1,sn
            if (pred_s(j:j) == '?') pred_s(j:j) = 'a'
        end do
        ans = min(ans,pred_s)
    end do
    if (ans /= 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') then
        print'(a)', trim(ans)
    else
        print'(a)', 'UNRESTORABLE'
    end if
end program abc076

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    string s;
    cin >> s;
    
    for (int i = 0; i < sz(s); ++ i) {
    	if ((i + 1) % 2 == 1) {
    		if (s[i] == 'R' or s[i] == 'U' or s[i] == 'D')
    			continue;
    		else
    			return cout << "No", 0;
    	}
    	if ((i + 1) % 2 == 0) {
    		if (s[i] == 'L' or s[i] == 'U' or s[i] == 'D')
    			continue;
    		else
    			return cout << "No", 0;
    	}
    }
    
    cout << "Yes";
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    return 0;
}


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


using ll = long long;
#define reps(i,s,n) for(ll (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;

int getDigitSum(int x){
    int ret = 0;
    while(x > 0){
        ret += (x % 10);
        x /= 10;
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    int ans = getDigitSum(n-1) + getDigitSum(1), tmp = 0;
    reps(i,2,n){
        tmp = getDigitSum(i) + getDigitSum(n-i);
        if(ans > tmp){ ans = tmp;
            
        }
    }

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

Measured memory_bytes: 256