akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef unsigned int uint;

void solve(){
	int n, p[110];
	cin >> n;
	rep(i, n) cin >> p[i];
	int sum = 0;
	rep(i, n) sum += p[i];
	if(sum % 10) printf("%d\n", sum);
	else {
		int mn = sum;
		rep(i, n) if(p[i] % 10) mn = min(mn, p[i]);
		printf("%d\n", sum - mn);
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = nextIntArray();
		long output = list.get(0);
		for(int i = 1; i < N; i++){
			output = gcd(output, list.get(i));
		}
		myout(output);
	}
	//Method addition frame start

static long gcd(long m, long n) {return n != 0 ? gcd(n, m % n) : m;}

	//Method addition frame end
}


Measured memory_bytes: 48592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=1e5+10;
const ll mod=1e9+7;
double x[mn],y[mn];
double eps=1e-13;
char d[mn];
int n;
double eval(long double t){
    long double x1=1e300,x2=-x1,y1=x1,y2=x2;
    for(int i=0;i<n;i++){
        if(d[i]=='U'){
            x1=min(x1,x[i]+0.L);
            x2=max(x2,x[i]+0.L);
            y1=min(y1,y[i]+t);
            y2=max(y2,y[i]+t);
        }
        else if(d[i]=='D'){
            x1=min(x1,x[i]+0.L);
            x2=max(x2,x[i]+0.L);
            y1=min(y1,y[i]-t);
            y2=max(y2,y[i]-t);
        }
        else if(d[i]=='R'){
            x1=min(x1,x[i]+t);
            x2=max(x2,x[i]+t);
            y1=min(y1,y[i]+0.L);
            y2=max(y2,y[i]+0.L);
        }
        else{
            x1=min(x1,x[i]-t);
            x2=max(x2,x[i]-t);
            y1=min(y1,y[i]+0.L);
            y2=max(y2,y[i]+0.L);
        }
    }
    return (x2-x1)*(y2-y1);
}
int main(){
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%lf %lf %c",x+i,y+i,d+i);
    long double l=0,r=1e9;
    for(int i=0;i<200;i++){
        long double a=(2*l+r)/3,b=(2*r+l)/3;
        if(eval(b)>eval(a))r=b;
        else l=a;
    }
    printf("%.20f",eval(l));
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    string s;
    cin >> s;

    int ans = 0;
    rep(i, s.size()){
        if(s[i] == 'A'){
            for (int j = s.size()-1; j >= 0; --j) {
                if(s[j] == 'Z'){
                    ans = j - i + 1;
                    cout << ans << endl;
                    return 0;
                }
            }
        }
    }


    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> data;
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        data.emplace_back(a, b);
    }
    i64 ans = 0;
    sort(WHOLE(data));
    auto itor = data.begin();
    priority_queue<int> rewards;
    for(int d = 1; d <= M; d++) {
        while(itor != data.end() && itor->first <= d) {
            rewards.push(itor->second);
            itor++;
        }
        if(rewards.empty()) continue;
        ans += rewards.top();
        rewards.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<unordered_map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<memory>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)   a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll N; cin >> N;
    ll sum =0;
    while(sum<N){
        sum+=1000;
    }
    cout << sum-N << endl;
}

int main(){
    a();
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
  // 入力 A B
  int a, b, ret;
  scanf("%d %d", &a, &b);
  for (ret = 0; ret <= 10000; ret++) {
    if ((ret * 8) / 100 == a	// 8%
	&& (ret * 10) / 100 == b) {
      printf("%d\n", ret);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 128
n = int(input())
num_list = [ int(v) for v in input().split() ]

ans = 0
for i in range(1,n-1):
    if min(num_list[i-1],num_list[i],num_list[i+1]) != num_list[i] and max(num_list[i-1],num_list[i],num_list[i+1]) != num_list[i]:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include "math.h"
using namespace std;
int main() {
	int N, m, s1, s2;
	cin >> N;
	vector<int> w(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i];
	}
	for (int i = 0; i < N; i++) {
		s1 = 0;
		s2 = 0;
		for (int j = 0; j < i; j++) {
			s1 += w[j];
		}
		for (int j = i; j < N; j++) {
			s2 += w[j];
		}
		if (i == 0) {
			m = abs(s2 - s1);
		}
		else {
			if (abs(s2 - s1) < m) {
				m = abs(s2 - s1);
			}
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    return gcd(b,a%b);
}

int main() {
    int n;
    cin>>n;
    int prev=0;
    for(int i=0;i<n;++i){
        int a;
        cin>>a;
        prev=gcd(prev,a);
    }
    cout<<prev<<endl;
    return 0;
}


Measured memory_bytes: 256
import string,sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
abc = string.ascii_lowercase
def main(N):
    if N<=26:
        return abc[N-1]
    if N%26==0:
        return main(N//26-1)+abc[-1]
    return main(N//26)+abc[N%26-1]
print(main(N))


Measured memory_bytes: 9884
#include<bits/stdc++.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

int main(){
  int x, a, b;
  cin >> x >> a >> b;

  if(b-a <= 0){
    cout << "delicious" << endl;
  }
  else if(b-a <= x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }

  return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    int main()
    {
         ll n,k;
     
         cin>>n>>k;
     
         if(n%k==0)
              cout<<0<<endl;
         else if(n<k)
         {
              if((n%k)<(k-n))
                   cout<<n<<endl;
              else
                   cout<<abs(n-k)<<endl;
         }
         else
         {
              n = n%k;
              cout<<k-n<<endl;
         }
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>  
using namespace std;  
typedef long long LL;  
#define pll pair<LL, LL>  
#define pii pair<int, int>  
#define X first  
#define Y second  
#define MAXN 1000010//1e3  
#define lson l, mid, (rt << 1)  
#define rson mid + 1, r, (rt << 1 | 1)  
const double eps = 1e-10;  
int n;  
vector<int> root, edge[MAXN];  
LL value[MAXN], cost[MAXN];  
bool cmp(int i, int j) {  
    return value[i] < value[j];  
}  
void init() {  
    root.clear();  
    for(int i = 0; i <= n; i++) {  
        edge[i].clear();  
        cost[i] = -1;  
    }  
}  
void solve(int rt) {  
    queue<int> q;  
    stack<int> s;  
    q.push(rt); s.push(rt);  
    while(!q.empty()) {  
        int tmp = q.front();  
        q.pop();  
        int len = edge[tmp].size();  
        for(int i = 0; i < len; i++) {  
            q.push(edge[tmp][i]);  
            s.push(edge[tmp][i]);  
        }  
    }  
    while(!s.empty()) {  
        int tmp = s.top();  
        s.pop();  
        sort(edge[tmp].begin(), edge[tmp].end(), cmp);  
        int len = edge[tmp].size();  
        cost[tmp] = 0LL;  
        LL res = 0;  
        for(int i = 0; i < len; i++) {  
            cost[tmp] += res + cost[edge[tmp][i]];  
            res += value[edge[tmp][i]];  
        }  
        value[tmp] += res;  
    }  
}  
int main() {  
    while(~scanf("%d", &n)) {  
        init();  
        int x;  
        for(int i = 0; i < n; i++) {  
            scanf("%lld%d", &value[i], &x);  
            if(x == -1) root.push_back(i);  
            else edge[x].push_back(i);  
        }  
        int len = root.size();  
        LL ans = 0;  
        for(int i = 0; i < len; i++) {  
            solve(root[i]);  
            ans += cost[root[i]];  
        }  
        printf("%lld\n", ans);  
    }  
    return 0;  
}  

Measured memory_bytes: 77316
#include <iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;
void solve() {

}
int main() {
    int a,b,c,k; cin >> a >> b >> c >> k;
    long long ans = 0;
    if (k >= a) {
        ans += a;
        k-= a;
    }
    else {
        ans += k;
        cout << ans;
        return 0;
    }
    if (k == 0) {
        cout << ans; return 0;
    }
    if (k >= b) {
        k -= b;
    }
    else {
        cout << ans;
        return 0;
    }
    if (k == 0) {
        cout << ans; return 0;
    }
    if (k >= c) {
        ans -= c;
    }
    else {
        ans -= k;
    }
    cout << ans << endl;


}



Measured memory_bytes: 3624
def main():
  n = int(input()) + 1
  a = [int(x) for x in input().split()]
  q = [0] * n
  for i in range(n):
    q[i] = (q[i - 1] - a[i - 1]) * 2 if i != 0 else 1
    # print(q[i])
    if q[i] <= 0:
      print(-1)
      return
  
  if q[n - 1] < a[n - 1]:
    print(-1)
    return
  q[n - 1] = a[n - 1]
  s = q[n - 1]
  # print('--')
  # print(q[n - 1])
  for i in range(n - 2, -1, -1):
    q[i] = min(q[i], q[i + 1] + a[i])
    if q[i] == 0:
      print(-1)
      return
    # print(q[i])
    s += q[i]
  print(s)

main()


Measured memory_bytes: 699532
using System;
using System.Linq;
using static System.Console;

class P
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var enemy = ReadLine().Split().Select(long.Parse).OrderBy(a=>-a).Skip(n[1]).Sum();
        WriteLine(enemy);
    }
}

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

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

    string n;
    cin >> n;
    ll ans = 0;

    for (ll i = 0; i < n.size(); i++){
        ans += (n[i] - '0');
    }

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

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h=0;
	int w=0;
	int n=0;
	int m=0;
	int ans=0;
	cin>>h;
	cin>>w;
  	cin>>n;
	if(w>h)
	{
		h=w;
	}
	while(m<n)
	{
		m+=h;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n,m,k = map(int,input().split())
f = [[] for _ in range(n)]
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    f[a].append(b)
    f[b].append(a)
for _ in range(k):
    c,d = map(int,input().split())
    c,d = c-1,d-1
    g[c].append(d)
    g[d].append(c)
d = {}
parent = [-1]*n
seen = [False]*n
from collections import deque
for i in range(n):
    if seen[i]: continue
    stack = deque()
    d[i] = set([i])
    stack = [i]
    while stack:
        v = stack.pop()
        seen[v] = True
        parent[v]=i
        for nv in f[v]:
            if seen[nv]: continue
            d[i].add(nv)
            stack.append(nv)
ans = [0]*n
for i in range(n):
    group = d[parent[i]]
    sum = len(group) -len(f[i]) - len(set(g[i])&group) -1
    ans[i]=sum
print(*ans)

Measured memory_bytes: 145448
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)
#define forl(n) for (ll i = 0 ; i < n ; i++)

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    for1(s.length()) {
        s = s[s.length() - 1] + s.substr(0, s.length() - 1);
        if (s == t) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3636
N = int(input())
S = input()
w = [0] * (N+1)
e = [0] * (N+1)
for i in range(N):
    if S[i] == 'W':
        w[i+1] = w[i] + 1
        e[i+1] = e[i]
    if S[i] == 'E':
        e[i+1] = e[i] + 1
        w[i+1] = w[i]
ans = 10 ** 6
for i in range(N):
    ans = min(ans, w[i] + e[N] - e[i + 1])
print(ans)

Measured memory_bytes: 17536
import Text.Printf
import Data.IORef
import Control.Monad
import Debug.Trace
import Data.Char

mytrace a = trace (show a) a

main :: IO ()
main = do
  [a, b, c, d] <- map digitToInt <$> getLine :: IO [Int]
  results <- newIORef []
  forM_ [1, 2] $ \i -> do
    let op1 = if i == 1 then (+) else (-)
    forM_ [1, 2] $ \j -> do
      let op2 = if j == 1 then (+) else (-)
      forM_ [1, 2] $ \k -> do
        let op3 = if k == 1 then (+) else (-)
        when (op3 (op2 (op1 a b) c) d == 7) $ do
          acc <- readIORef results
          writeIORef results ((i, j, k):acc)

  (i, j, k) <- head <$> readIORef results
  putStrLn $ printf "%d%s%d%s%d%s%d=7" a (opshow i) b (opshow j) c (opshow k) d

opshow :: Int -> String
opshow 1 = "+"
opshow 2 = "-"


Measured memory_bytes: 508
S = list(input())
Max = 0
count = 0
for i in range(len(S)):
    if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
        count+=1
        if count>Max:
            Max=count
    else:
        count=0
print(Max)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
 
using namespace std;
 
typedef long long lli;
 
const lli N = 1000;
const lli M = 1000000;
 
lli n, dp[N+1], t[17];
string data[N];
string pat[4][4] = {
  {"0xxxxxxx", "", "", ""},
  {"110yyyyx", "10xxxxxx", "", ""},
  {"1110yyyy", "10yxxxxx", "10xxxxxx", ""},
  {"11110yyy", "10yyxxxx", "10xxxxxx", "10xxxxxx"},
};
 
main(){
  t[0] = 1;
  for(lli i=1;i<17;i++) t[i] = (t[i-1] * 2) % M;
  while(cin >> n && n){
    for(lli i=0;i<n;i++) cin >> data[i];
    fill(dp, dp+n+1, 0);
    dp[0] = 1;
    for(lli i=0;i<n;i++){
      for(lli j=0;j<4&&i+j<n;j++){
        bool f = true;
        int f_y = 0;
        if(j == 0) f_y = true;
        lli cnt[2] = {0, 0};
        for(lli k=0;k<=j;k++){
          for(lli l=0;l<8;l++){
            if(data[i+k][l] != 'x' && pat[j][k][l] != 'x' && pat[j][k][l] != 'y' && data[i+k][l] != pat[j][k][l]){
f = false;
            }
            if(data[i+k][l] == '1' && pat[j][k][l] == 'y') f_y = 2;
            if(data[i+k][l] == 'x'){
              if(pat[j][k][l] == 'x') cnt[0]++;
              if(pat[j][k][l] == 'y'){
                cnt[1]++;
                f_y = max(f_y, 1);
              }
            }
          }
        }
        if(!f_y) f = false;
        if(f){
          lli val = t[cnt[0]];
          if(cnt[1]){
            if(f_y == 2) val = (val * t[cnt[1]]) % M;
            else val = (val * ((t[cnt[1]] - 1 + M) % M)) % M;
          }
          dp[i+j+1] = (dp[i+j+1] + dp[i] * val) % M;
        }
      }
    }
    cout << dp[n] << endl;
  }
}

Measured memory_bytes: 1272
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    string S;
    cin >> S;
    vector<string> youbi = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, youbi.size()) {
        if (youbi[i] == S) {
            cout << 7 - i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(2);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

void solve()
{
	string s;
	cin>>s;

	int n=0;
	for(char c : s)
	{
		int x = c - '0';
		n+=x;
	}

	if(n%9==0) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		char s[] = getString().toCharArray();
		char t[] = getString().toCharArray();
		int ans = ( s[0]==t[0] ? 1 : 0 ) + ( s[1]==t[1] ? 1 : 0 ) + ( s[2]==t[2] ? 1 : 0 ) ;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21588
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    loop {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        let mut ws = buf.split_whitespace();
        let x: i32 = ws.next().unwrap().parse().unwrap();
        let y: i32 = ws.next().unwrap().parse().unwrap();

        if x == 0 && y == 0 {
            break;
        } else if x < y{
            println!("{} {}", x, y);
        } else {
            println!("{} {}", y, x);
        }
    }
}



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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

ll modpow(ll a, ll x)
{
    ll res = 1;
    while(x > 0)
    {
        if(x & 1) res = res * a % MOD;
        a = a * a % MOD;
        x >>= 1;
    }
    return res % MOD;
}

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

    ll N; cin >> N;
    ll ans = modpow(10, N) + modpow(8, N);
    ans %= MOD;
    ans -= modpow(9, N);
    ans = (ans+MOD) % MOD;
    ans -= modpow(9, N);
    ans = (ans+MOD) % MOD;
    cout << (ans + MOD) % MOD << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<int> A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList();
            List<int> B = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList();
            List<int> C = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList();
            int mannzokudo = 0;
            for(int i = 0; i < N; i++)
            {
                mannzokudo += B[A[i] - 1];
                if(i > 0 && A[i-1] == A[i] - 1)
                {
                    mannzokudo += C[A[i - 1] - 1];
                }
            }
            Console.WriteLine(mannzokudo);
        }
    }
}

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

int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	set<int> puni, muni;
	for(int i = 0; i * 100 * a <= f; i++){
		for(int j = 0; i * 100 * a + j * 100 * b <= f; j++){
			puni.insert(i * 100 * a + j * 100 * b);
		}
	}
	for(int i = 0; i * c <= f; i++){
		for(int j = 0; i * c + j * d <= f; j++){
			muni.insert(i * c + j * d);
		}
	}
	pair<int, int> ans(-1, -1);
	for(int x:puni){
		for(int y:muni){
			if(f < x + y) continue;
			if(100 * y <= e * x){
				if(ans.first == -1){
					ans = make_pair(x, y);
					continue;
				}
				if(ans.second * (x + y) <= y * (ans.first + ans.second)){
					ans = make_pair(x, y);
				}
			}
		}
	}
	cout << ans.first + ans.second << ' ' << ans.second << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    cout << a - (s == u) << ' ' << b - (t == u) << '\n';
}


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

int xx[1000] , yy[1000];
int wf[1000][1000];
int main(){
	int n,X,Y;
	cin >> n;
	while(cin >> n >> X >> Y && n){
		memset(wf,0,sizeof(wf));
		int sx , sy = 0;
		cin >> sx >> sy;
		for(int i = 0 ; i < n ; i++){
			int x,y; cin >> x >> y;
			xx[i] = x , yy[i] = y;
		}
		for(int i = 0 ; i < n ; i++)
			for(int j = 0 ; j < n ; j++)
				if( i != j && (xx[i]-xx[j])*(xx[i]-xx[j])+(yy[i]-yy[j])*(yy[i]-yy[j]) <= 2500 ) wf[i][j] = 1;
		int p[1000];
		int q[1000];
		for(int i = 0 ; i < 1000 ; i++)
			p[i] = -1 , q[i] = -1;
		for(int i = 0 ; i < n ; i++){
			if((sx-xx[i])*(sx-xx[i])+(sy-yy[i])*(sy-yy[i]) <= 100){
				p[i] = X;
			}
		}
		bool flag; int cnt = 0;
		while(cnt != 10000){
			flag = false;/*
			for(int j = 0 ; j < n ; j++) 
				cout << p[j] << " " << q[j] << endl;
			cout << endl;*/
			for(int i = 0 ; i < n ; i++){
				if(p[i] > 0){
					flag = true;
				}
				p[i]--;
				q[i]--;
			}
			for(int i = 0 ; i < n ; i++){
				if(p[i] == 0){
					q[i] = Y;
				}
			}
			for(int i = 0 ; i < n ; i++){
				if(p[i] == 0){
					for(int j = 0 ; j < n ; j++){
						if(wf[i][j] && q[j] < 0){
							p[j] = X;
							flag = true;
						}
					}
				}
			}
			if(!flag) break;
			cnt++;
		}
		if(cnt == 10000) cout << "You're always welcome!" << endl;
		else cout << cnt << endl;
	}	
}
/*
11011

*/

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long []a = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextLong();
		}
		scan.close();

		long p = 0;
		for(int i = 0; i < N; i++) {
			p += num2(a[i]);
		}

		if(p == 0) {
			System.out.println(0);
		}else {
			System.out.println(p - N);
		}

	}
	public static int num2(long n) {
		for(int i = 0; i < 10000; i++) {
			long t = (long)Math.pow(2, i + 1);
			if(n % t != 0) {
				return i + 1;
			}
		}
		return 0;
	}
}

Measured memory_bytes: 34224
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define   ll   long long
#define   llu  unsigned long long
#define   _    printf("\n")
int      take() {
    int n;
    scanf("%d",&n);
    return n;

}
double  ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll     takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define  Int            take()
#define  Dnt            ttake()
#define  LL             takes()
#define  done           {return 0;}
#define  fr(i,x,n,a)    for(int i=x;i<=n;i+=a)
#define  FR(a,b,x)      for(int i=(a);i<=(b);i+=(x))
#define  rfr(i,x,n,a)   for(int i=x;i>=n;i--)
int      cas;
#define  print          printf("Case %d:",++cas)
#define  vi             vector<int>
#define  vl              vector<ll>
#define  pb              push_back
#define  pii             pair<int,int>
#define  vii             vector<pii>
#define  pll             pair<ll,ll>
#define  pil             pair<int,ll>
#define  pli             pair<ll,int>
#define  mk              make_pair
#define  fill(x,v)       memset(x,v,sizeof x)

using    namespace      std;

bool     approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define  STR            {struct info}
#define  dbg(x)         {cout<<"ekhane"<<x<<endl;}
#define  SS             second
#define  FF             first
#define  PQ             priority_queue
#define  great          greatest
#define  less           lesser
#define  mii            map<int,int>
#define  mil            map<int,ll>
#define  mll            map<ll,ll>
#define  msb            map<string,bool>
#define  V              vector
#define  M              100005
#define  pf             printf
//////////////////////////////////////////


int main(){

   int a = Int , b = Int , c = Int , d = Int ;
    if( abs( a - c ) <= d || ( abs( a - b )<=d && abs( b - c )<=d )){
        pf("Yes\n") ;
    }else pf("No\n") ;
    done;
}




Measured memory_bytes: 256
def solve():
    s = input()
    if len(str(s)) != 4:
        raise Exception('Error')
    if not (s.isdecimal()):
        print('NA')
    else:
        sl = list(s)
        st = int("".join(sl[:2]))
        end = int("".join(sl[2:4]))
        if st > 0 and st <= 12 and end > 0 and end <= 12:
            print('AMBIGUOUS')
        elif st > 0 and st <= 12 and (end == 0  or end > 12):
            print('MMYY')
        elif (st == 0 or st > 12) and end > 0 and end <= 12:
            print('YYMM')
        else:
            print('NA')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
import java.util.Scanner;

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

		while (true){
			int length = sc.nextInt();
			// 0 なら終了
			if (length == 0){
				break;
			}

			int[] a = new int[length];
			int[] b = new int[length];
			int score_a = 0;
			int score_b = 0;

			for (int i = 0; i < length; i++){
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();

				if (a[i] > b[i]){
					score_a += a[i] + b[i];
				}else if (a[i] < b[i]){
					score_b += a[i] + b[i];
				}else{
					score_a += a[i];
					score_b += b[i];
				}
			}

			// 出力
			System.out.println(score_a + " " + score_b);
		}
	}
}

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

#define LIVE (0)
#define DEAD (1)

int md[1000];

int fizzbuzz(int n)
{
	if (n % 15 == 0){
		return (-3);
	}
	if (n % 3 == 0){
		return (-1);
	}
	if (n % 5 == 0){
		return (-2);
	}
	return (n);
}
void inc_no(int *no, int m)
{
	do {
		(*no)++;
		if (*no >= m){
			*no = 0;
		}
	} while (md[*no] == DEAD);
}

int main(void)
{
	int n, m;
	int nd;
	char data[20];
	int i;
	int no;
    int remain;
    int out_flag;
	
	while (1){
		scanf("%d%d", &m, &n);
		if (n == 0 && m == 0){
			break;
		}
		for (i = 0; i < 1000; i++){
			md[i] = LIVE;
		}

		no = 0;
        remain = m;
		for (i = 1; i <= n; i++){
			scanf("%s", data);
			if (strcmp(data, "Fizz") == 0){
				nd = -1;
			}
			else if (strcmp(data, "Buzz") == 0){
				nd = -2;
			}
			else if (strcmp(data, "FizzBuzz") == 0){
				nd = -3;
			}
			else {
				nd = atoi(data);
			}
			if (nd != fizzbuzz(i)){
				md[no] = DEAD;
                if (--remain == 1){
              		for (i++; i <= n; i++){
			            scanf("%s", data);
            		}
                    break;
                }
			}
			inc_no(&no, m);
		}
        out_flag = 0;
		for (i = 0; i < m; i++){
			if (md[i] == LIVE){
                if (out_flag == 1){
                    printf(" ");
                }
				printf("%d", i + 1);
                out_flag = 1;
			}
		}
		printf("\n");
	}

	return (0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
string s,t;
cin>>s>>t;
sort(s.begin(),s.end());
sort(t.begin(),t.end(),greater<char>());
if(s<t)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

 }

 


 






    





      

        


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <stack>
using namespace std;

int main() {
	string s;
	cin >> s;
	char pre = s[0];
	for (int i = 1; i < 3; i++) {
		if (s[i] != pre) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";

}

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


int f(int n)
{
    int cnt[100] = {0};
    for (int x = 1; x <= n; x++) {
        int d1 = x;
        while (d1 >= 10) d1 /= 10;
        int d2 = x % 10;
        if (d2 > 0) cnt[d1*10+d2]++;
    }
    int ans = 0;
    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
            ans += cnt[i*10+j] * cnt[j*10+i];
    return ans;
}


int main()
{
    int n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    sort(A.rbegin(), A.rend());
    int sum = accumulate(A.begin(), A.end(), 0);
    for(int i=0; i<M; i++) {
        if(4*M*A[i] < sum) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    int ans = 0;

    auto zal = [&](vi &Z, string &S) {
        int num = S.size();
        Z.resize(num);
        Z[0] = num;
        int i = 1, j = 0;
        while(i < num) {
            while(i+j < num and S[j] == S[i+j]) j++;
            Z[i] = j;
            
            if(!j) {
                ++i;
                continue;
            }

            int k = 1;
            while(i+k < num and k+Z[k] < Z[i]) {
                Z[i+k] = Z[k];
                ++k;
            }
            i += k;
            j -= k;
        }
    };


    vi Z;
    rep(i, n-1) {
        zal(Z, s);
        rep(j, n-1) {
            if(!j) continue;
            ans = max(ans, min(j, Z[j]));
        }
        s = s.substr(1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 100005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;



int main() {
    ll sum = 0, n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3 == 0 || i%5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,s=0,p,i;
cin>>p>>n;
long long a[n];
for(i=0;i<n;i++){
    cin>>a[i];
    s=s+a[i];

}p=p-s;
if(p<0)
cout<<-1;
else
cout<<p;
    return 0;
  
}


Measured memory_bytes: 3708
var dx = { N: 0, S: 0, E: 1, W: -1};
var dy = { N: 1, S: -1, E: 0, W: 0};

function Main(input){
    input = input.split("\n");
    var k = 0;
    while(1){
        var n = parseInt(input[k++],10);

        if(n == 0)
            break;

        var a = [];
        for(var i = 0;i <= 20;i++){
            a[i] = [];
            for(var j = 0;j <= 20;j++)
                a[i][j] = false;
        }
        for(var i = 0;i < n;i++){
            input[k] = input[k].split(" ");
            a[parseInt(input[k][0],10)][parseInt(input[k++][1],10)] = true;
        }

        var m = parseInt(input[k++],10);

        var op = [],dis = [];

        for(var i = 0;i < m;i++){
            input[k] = input[k].split(" ");
            op[i] = input[k][0];
            dis[i] = parseInt(input[k++][1],10);
        }

        var get = 0;

        var x = 10,y = 10;
        if(a[x][y]){
            a[x][y] = false;get++;
        }

        for(var i = 0;i < m;i++){
            for(var j = 0;j <dis[i];j++){
                x += dx[op[i]];
                y += dy[op[i]];
                if(a[x][y]){
                    a[x][y] = false;get++;
                }
            }
        }
        if(get == n)
            console.log("Yes");
        else
            console.log("No");
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

int main(){
  int N,Y;
  cin >> N >> Y;
  bool ex = false;
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N-i; j++){
      int sum = i*10000 + j*5000 + (N-i-j)*1000;
      if(sum == Y){
        ex = true;
        cout << i << " " << j << " " << (N-i-j) << endl;
        break;
      }
      if(ex){
        break;
      }
    }
    if(ex){
      break;
    }
  }
  if(!ex){
    cout << "-1 -1 -1" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, ll> pill;
 
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
 
const int maxn = 4e3 + 5;
const ll mod = 1e9+7;
const double PI = acos(-1.0);
 
int n;
int u[200005],v[200005];
ll fac[2*maxn],infac[2*maxn];
ll cnt[maxn][maxn];
 
ll po(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1)
		{
			res =(res*x)%mod;
		}
		x=x*x%mod;
		y=y>>1;
	}
	return res;
}
 
void init()
{
	int i,j,k;
	
	fac[0]=1;
	
	for(i=1;i<=8000;i++)
	{
		fac[i]=(fac[i-1]*i)%mod;
		infac[i]=po(fac[i],mod-2);
	}
}
 
ll cal(int x,int y)
{
	return ((fac[x+y]*infac[x])%mod*infac[y])%mod;
}
 
void solve()
{
	int i,j,k;
	
	memset(cnt,0,sizeof(cnt));
 
	for(i=1;i<=n;i++)
	{
		sa(u[i]),sa(v[i]);
		cnt[2000-u[i]][2000-v[i]]++;
	}
	for(i=0;i<=4000;i++)
	{
		for(j=0;j<=4000;j++)
		{
			if(i>0)
			{
				cnt[i][j] = (cnt[i][j]+cnt[i-1][j])%mod;
			}
			if(j>0)
			{
				cnt[i][j] = (cnt[i][j]+cnt[i][j-1])%mod;
			}
		}
	}
	ll r=0;
	for(i=1;i<=n;i++)
	{
		r = (r+cnt[2000+u[i]][2000+v[i]])%mod;
		r = ((r-cal(2*u[i],2*v[i]))%mod+mod)%mod;
	}
	r = (r*po(2,mod-2))%mod;
	printf("%lld\n",r);
}
 
int main()
{
    init();
    while(scanf("%d",&n)!=EOF)
    {
    	solve();
    }
    return 0;
}
/*
int main()
{
#ifndef ONLINE_JUDGE
    freopen("/Users/2997ms/Desktop/eve/algorithm/algorithm/i.txt", "r", stdin);
    //freopen("/Users/2997ms/Desktop/eve/algorithm/algorithm/o.txt", "w", stdout);
#endif  
	 solve();
	 return 0;
}

*/

Measured memory_bytes: 127232
#include<cstdio>
#include<cstring> 
#include<iostream>
#include<set>
using namespace std;
#define INF 1000000000
int a[100005];
int n,ans=0;
multiset<int>l;
multiset<int>::iterator q;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
q=l.lower_bound(a[i]);
if(q==l.begin()){
l.insert(a[i]);
ans++;
}
else {
q--;
l.erase(q);
l.insert(a[i]);
}
}
printf("%d\n",ans);
}


Measured memory_bytes: 8908
using System;
using System.Linq;

class P
{
  static void Main()
  {
    var a = Console.ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToList();
    if(a[0] < a[1] && a[1] < a[2]) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 9344