akhauriyash/Code-Regression huggingface dataset:
#include <cstdint>
#include <iostream>
#include <unordered_map>

using namespace std;

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

  int N;
  cin >> N;
  unordered_map<int64_t, int> m;
  m[0] = 1;

  int64_t sum = 0;
  int64_t ans = 0;
  int a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    sum += a;
    ans += m[sum];
    m[sum]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;

ll ans = 0;





int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    vector<vector<ll>> DP(N+1, vector<ll>(K+1));
    
    for(int i = 0; i < N+1; i++) DP[i][0] = 1;
    for(int i = 0; i <= A[0]; i++) DP[1][i] = 1;

    vector<ll> D = DP[1];
    for(int i = 1; i < K+1; i++) D[i] = (D[i-1] + D[i])%MOD;

    for(int i = 2; i <= N; i++){
        ll a = A[i-1];
        for(int j = 1; j <= K; j++){
            if( j <= a) DP[i][j] = D[j];
            else {
                DP[i][j] = (D[j]-D[j-a-1])%MOD;
                if(DP[i][j] < 0) DP[i][j] += MOD;
            }
        }
        // 累積和の計算のし直し
        D = DP[i];
        for(int i = 1; i < K+1; i++) D[i] = (D[i-1]+D[i])%MOD;
    }
    cout << DP[N][K]%MOD << endl;

    


}

Measured memory_bytes: 80256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
#define N 200010
int a[N],b[N],cnt[N];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int n,m,i;
	scanf("%d%d",&n,&m);
	int ans=n;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		int tmp=a[i]-cnt[a[i]]+1;
		if(tmp>0){
			if(!b[tmp])
			ans--;
			b[tmp]++;
		}
	}
	for(i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		int tmp=a[x]-cnt[a[x]]+1;
		if(tmp>0){
			if(b[tmp]==1)
			ans++;
			b[tmp]--;
		}
		cnt[a[x]]--;
		cnt[y]++;
		a[x]=y;
		tmp=y-cnt[y]+1;
		if(tmp>0){
			if(!b[tmp])
			ans--;
			b[tmp]++;
		}
		printf("%d\n",ans);
	}
	//system("pause");
	return 0;
}

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


int main()
{
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n)
    rep(j, d)
      cin >> x[i][j];
  int ans = 0;
  rep(i, n - 1)
    for (int j=i+1; j<n; j++)
    {
      int dist = 0;
      rep(k, d)
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      for (int k=1; k * k <= dist; k++)
        if (k * k == dist)
          ans ++;
    }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

ll MOD = 1000000007;

int main() {
  ll N, M;
  cin >> N >> M;

  vi v(N);
  for (ll i = 0; i < N; i++) {
    cin >> v[i];
  }

  vi x(N + 1);
  for (ll i = 0; i < N; i++) {
    x[i + 1] = x[i] + v[i];
  }

  unordered_map<ll, ll> m;
  for (ll i = 0; i <= N; i++) {
    m[x[i] % M] += 1;
  }

  ll ans = 0;
  for (auto p: m) {
    ans += p.second * (p.second - 1) / 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 5260
n, k = map(int, input().split())

a = 0
for i in range(1, n+1):
    if i >= k:
        a += 1
        continue
    cnt = 0
    score = i
    while score <= k-1:
        score *= 2
        cnt += 1
    a += (1 / 2) ** cnt

ans = (1/n) * a
print(ans)

Measured memory_bytes: 3060
class A042
  def call(a, b, c)
    (a == 5 || a== 7) &&
        (b == 5 || b== 7) &&
        (c == 5 || c== 7) &&
        a + b + c == 17
  end

  def main
    inputs = gets.split(' ')
    if call(inputs[0].to_i, inputs[1].to_i, inputs[2].to_i)
      puts 'YES'
    else
      puts 'NO'
    end
  end
end

A042.new.main

Measured memory_bytes: 14188
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };
int h[105];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> h[i];
	int cnt = 0;

	rep(i, n) {
	A:;
		if(h[i]){
			for (int j = i + 1; j <= n; j++) {
				if (!h[j]) {
					for (int k = i; k < j; k++)h[k]--;
					cnt++;
					goto A;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,saidai=0;
    cin >> n;
    vector<int> a(n),b;
    for (int i=0;i<n;i++){
        cin>>a.at(i);
    }
    b=a;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    saidai=b.at(0);
    for(int i=0;i<n;i++){
        if(saidai==a.at(i)){
            cout<<b.at(1)<<endl;
        }else{
            cout<<b.at(0)<<endl;
        }
    }
    
}


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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   string s , t;
   cin >> s >> t;
   int n = s.length();
   int ans = 0;
   for(int i = 0 ; i < n ; i++)
      ans += (s[i] != t[i]);
   cout << ans;
   return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using ll = long long int;
using namespace std;

#define FOR(i,N) for(int i=0;i<N;i++)
#define pb(x) push_back(x)

int main() {
    string s, t;
    cin >> s;
    t = s;
    reverse(s.begin(), s.end());
    int cnt = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != t[i])cnt++;
    }

    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

long calc(int n) {
    if (n == 1) return 1;

    long a = 2;
    long b = 1;
    for (int i = 2; i <= n; i++) {
        long c = a + b;
        a = b;
        b = c;
    }
    return b;
}

void main() {
    int n = readint;
    writeln(calc(n));
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010,inf=1e9;
int n,m,x,y,z,tot, front, rear;
int dist[maxn], h[maxn*10];
bool v[maxn];
void read(int &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
void spfa()
{
	for(int i=1;i<n;i++) dist[i]=i; dist[0]=n;
	rear=n; for(int i=1;i<=n;i++) h[i]=i-1, v[i-1]=1;
	while(front<rear)
	{
		int now=h[++front];
		for(int i=0, tmp;i<=9;i++)
		if(dist[tmp=(now*10+i)%n]>dist[now]+i)
		{
			dist[tmp]=dist[now]+i;
			if(!v[tmp]) v[tmp]=1, h[++rear]=tmp%n;
		}
		v[now]=0;
	}
}
int main()
{
	read(n);
	spfa();
	printf("%d\n", dist[0]);
	return 0;
}

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

int main()
{
    set<int> s;
    int n;
    cin >> n;
    rep(i, n){
        int a;
        cin >> a;
        s.insert(a);
    }
    if(s.size() == n)cout << "YES" << endl;
    else{
        cout << "NO" << endl;
    }
    system("pause");
}

Measured memory_bytes: 9848
#include <stdio.h>

int main()
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int f;
  f = 1;
  while (a > 0 && c > 0)
  {
    if (f == 1)
      c -= b;
    else
      a -= d;
    f *= -1;
  }
  if (c <= 0)
  {
    printf("Yes");
  }
  else
    printf("No");
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin>> n;
    vector<pair<int,int>> a(n);
    rep(i,n){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(all(a));
    rep(i,n){
        if(i < n-1)
        cout << a[i].second << " ";
        else cout << a[i].second << endl;
    }
    return 0;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

struct Book
{
    int c;
    vector<int> v;
};

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

    int n, m, x;
    cin >> n >> m >> x;

    int t;
    vector<Book> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i].c;
        for (int j = 0; j < m; j++)
            cin >> t, v[i].v.push_back(t);
    }

    int ans = 2e9;
    for (int i = 0; i < (1 << n); i++)
    {
        int cst = 0, und[12] = {}, t = i;
        for (int j = 0; j < n; j++, t /= 2)
            if (t & 1)
            {
                cst += v[j].c;
                for (int k = 0; k < m; k++)
                    und[k] += v[j].v[k];
            }

        bool suc = true;
        for (int j = 0; j < m; j++)
            if (und[j] < x)
                suc = false;

        if (suc)
            ans = min(ans, cst);
    }
    if (ans == 2e9)
        cout << "-1\n";
    else
        cout << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 3664
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    String y = sc.next();
    String z = sc.next();
    System.out.print(x.charAt(0));
    System.out.print(y.charAt(1));
    System.out.println(z.charAt(2));
  }
}


Measured memory_bytes: 21588
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: AtCoder Crackers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (n % k == 0) ? 0 : 1);
  return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	//cout << s.substr(2, 1) << endl;
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	int n = s.size();

	string sub;
	for (int i = 2; i < n - 1; i++) {
		sub += s[i];
	}
	//cout << sub.c_str() << endl;

	//cout << sub.c_str() << endl;
	int cnt = 0;
	
	for (int i = 0; i < sub.size(); i++) {
		if (sub[i] == 'C')cnt++;
	}

	if (cnt != 1) {
		cout << "WA" << endl;
		return 0;
	}
	cnt = 0;
	for (auto c : s)if (c == 'C')cnt++;
	if (cnt >= 2) {
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 1; i < s.size(); i++) {
		if ('A' <= s[i] && s[i] <= 'Z') {
			if (s[i] != 'C') {
				cout << "WA" << endl;
				return 0;
			}
		}
	}
	cout << "AC" << endl;
	return 0;
}

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

int main(void)
{
	char str[7] = {
		0,
	};
	scanf("%s", str);
	if (str[2] == str[3] && str[4] == str[5])
		printf("Yes\n");
	else
	{
		printf("No\n");
	}

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)

int main(){
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  int num = 100001;
  Vector a(num,0);
  rep(i,n){
    int c;
    cin >> c;
    a[c]++;
  }
  int m = -1;
  rep(i,num){
    if(i==0)maxch(m,a[i+1]+a[i]);
    else if(i==num-1)maxch(m,a[i-1]+a[i]);
    else maxch(m,a[i-1]+a[i]+a[i+1]);
  }
  cout << m << endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split(" ")))

import collections
d = dict(collections.Counter(A))
ans = "No"
num = list(d.keys())
num.sort()
if len(d) == 1:
    if num[0] == 0:
        ans = "Yes"
elif len(d) == 2:
    if num[0] == 0 and d[0] * 3 == N:
        ans = "Yes"
elif len(d) == 3:
    if num[0] ^ num[1] == num[2] and d[num[0]] == d[num[1]] and d[num[2]] == d[num[1]]:
        ans = "Yes"
print(ans)

Measured memory_bytes: 16548
#![allow(non_snake_case)]
#![allow(unused_macros)]

use proconio::marker::Usize1;
use proconio::{fastout, input};

macro_rules! echo {
  {$x:expr} => {println!("{}", $x)}
}

macro_rules! chmax {
  {$x:expr, $y:expr} => {
    $x = std::cmp::max($x, $y)
  }
}

macro_rules! chmin {
  {$x:expr, $y:expr} => {
    $x = std::cmp::min($x, $y)
  }
}

#[allow(unused_variables)]
#[fastout]
fn main() {
  let R: usize;
  let C: usize;
  let K: usize;
  input! {
    R: usize,
    C: usize,
    K: usize,
  }
  let mut field = vec![vec![None; C]; R];
  for _ in 0..K {
    let r: usize;
    let c: usize;
    let v: usize;
    input! {
      r: Usize1,
      c: Usize1,
      v: usize,
    }
    field[r][c] = Some(v);
  }
  let mut dp = vec![vec![vec![0; 4]; C + 1]; R + 1];
  for i in 1..=R {
    for k in 1..=C {
      for num in 0..=3 {
        chmax!(dp[i][k][num], dp[i][k - 1][num]);
        chmax!(dp[i][k][0], dp[i - 1][k][num]);
      }
      if let Some(v) = field[i - 1][k - 1] {
        for num in (0..3).rev() {
          chmax!(dp[i][k][num + 1], dp[i][k][num] + v);
        }
      }
    }
  }
  echo!(dp[R][C].iter().max().unwrap());
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_H = 200005;

int R, C;
int N;
int SR, SC;
string S, T;

int dr[] = {0,0,-1,1};
int dc[] = {-1,1,0,0};

signed main()
{
  cin >> R >> C >> N;
  cin >> SR >> SC;
  cin >> S;
  cin >> T;

  SR--; SC--;

  // int tl = 0, tr = 0, al = 0, ar = 0;
  // int tu = 0, td = 0, au = 0, ad = 0;
  // REP(n,N) {
  //   if(S[n] == 'L') tl++;
  //   else if(S[n] == 'R') tr++;
  //   else if(S[n] == 'U') tu++;
  //   else if(S[n] == 'D') td++;
  // }  
  // REP(n,N) {
  //   if(T[n] == 'L') al++;
  //   else if(T[n] == 'R') ar++;
  //   else if(T[n] == 'U') au++;
  //   else if(T[n] == 'D') ad++;
  // }  

  //横方向(左から出れるか)
  int x = SC;
  REP(n,N) {
    if(S[n] == 'L') x--;
    if(x < 0) {
      cout << "NO" << endl;
      return 0;
    }
    if(T[n] == 'R' && x < C-1) x++;
  }

  //横方向(右から出れるか)
  x = SC;
  REP(n,N) {
    if(S[n] == 'R') x++;
    if(x >= C) {
      cout << "NO" << endl;
      return 0;
    }
    if(T[n] == 'L' && 0 < x) x--;
  }


  //上方向(上から)
  int y = SR;
  REP(n,N) {
    if(S[n] == 'U') y--;
    if(y < 0) {
      cout << "NO" << endl;
      return 0;
    }
    if(T[n] == 'D' && y < R-1) y++;
  }

  y = SR;
  REP(n,N) {
    if(S[n] == 'D') y++;
    if(y >= R) {
      cout << "NO" << endl;
      return 0;
    }
    if(T[n] == 'U' && 0 < y ) y--;
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 776
def main():
    n, m = map(int, input().split())
    xs = sorted(map(int, input().split()))
    dists = sorted(xs[i] - xs[i - 1] for i in range(1, len(xs)))
    if n > 1:
        print(sum(dists[: -n + 1]))
    else:
        print(sum(dists))


if __name__ == "__main__":
    main()


Measured memory_bytes: 13968
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <complex>
#include <string>
#include <sstream>
#include <iomanip>
#include <climits>
#include <functional>
#include <bitset>
#include <tuple>

using namespace std;

typedef long long  ll;

int main()
{
    int N;

    cin >> N;
    int c[N][N];

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

    ll res = 0;
    for (int i = 0; i < N; ++i)
        for (int j = i + 1; j < N; ++j)
            res += min(c[i][j], c[j][i]);

    cout << res << endl;

    return 0;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    if (a=="H"){
        if (b=="H"){
            cout<<"H";
        } else {
            cout<<"D";
        }
    } else {
        if (b=="H"){
            cout<<"D";
        } else {
            cout<<"H";
        }
    }
}

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

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

    int ans = 0;
    string t = "CODEFESTIVAL2016";

    for(int i = 0; i < 16; i++){
        if(s[i] != t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
p = 10**9+7
from math import factorial


if (x+y)%3 != 0:
    print(0)
    exit()



ans = 1
for i in range(0,x//2+2):
    j = x - 2*i
    if 2*j + i == y:
        a = i
        b = j
        break
else:
    print(0)
    exit()

for i in range(1,a+b+1):
    ans *= i%p
    ans %= p
ans %= p

a_inv = 1
for i in range(1,a+1):
    a_inv *= i%p
    a_inv %= p
a_inv = pow(a_inv,p-2,p)

b_inv = 1
for i in range(1,b+1):
    b_inv *= i%p
    b_inv %= p
b_inv = pow(b_inv,p-2,p)

ans *= (a_inv*b_inv)%p

print(ans%p)


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

namespace ABC152A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var N = NM[0];
            var M = NM[1];

            Console.WriteLine(N == M ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{

    int i,j,n,k,sum=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
                sum=sum+__gcd(i,__gcd(k,j));
            }
        }

    }
    cout<<sum<<endl;




}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vd vector<double>
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define P (ll)(1e9+7)
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int offset[]={1,0,-1,0,1};
int main()
{
    IP
    ll n,m;
    cin>>n>>m;
    vector<vl> adj(n+1);
    bool vis[n+1]={0};
    vl par(n+1,-1);
    f(i,0,m)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    queue<ll> q;
    q.push(1);
    vis[1]=1;
    while(!q.empty())
    {
        ll temp=q.front();
        q.pop();
       // vis[temp]=1;
        for(auto v:adj[temp])
        {
            if(!vis[v])
            {
                vis[v]=1;
                q.push(v);
                par[v]=temp;
            }
        }
        
    }
    bool found=1;
    f(i,1,n+1)
    found&=vis[i];
    if(found)
    {
        cout<<"Yes\n";
        f(i,2,n+1)
        {
            cout<<par[i]<<"\n";
        }
    }
    else cout<<"No\n";
    return 0;
}           

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

using namespace std;
#define ll long long
#define inf 998244353

int A[100005], B[100005], C[100005], Z[500005];
bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    int x, y, a, b, c;
    scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&A[i]);
    }
    for(int i=0;i<b;i++)
    {
        scanf("%d",&B[i]);
    }
    for(int i=0;i<c;i++)
    {
        scanf("%d",&C[i]);
    }
    sort(A,A+a,cmp);
    sort(B,B+b,cmp);
    sort(C,C+c,cmp);
    int ji=0;
    for(int i=0;i<x;i++)
    {
        Z[ji++]=A[i];
    }
    for(int i=0;i<y;i++)
    {
        Z[ji++]=B[i];
    }
    for(int i=0;i<c;i++)
    {
        Z[ji++]=C[i];
    }
    sort(Z,Z+x+y+c,cmp);
    ll z=0;
    for(int i=0;i<x+y;i++)
    {
        z=z+Z[i];
    }
    printf("%lld\n",z);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

ll dp[60][60][3000];

int main()
{
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    dp[0][0][0] = 1;
    rep(i, n) rep(j, n) rep(k, 3000)
    {
        dp[i + 1][j][k] += dp[i][j][k];
        if (k >= x[i])
            dp[i + 1][j + 1][k] += dp[i][j][k - x[i]];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += dp[n][i][i * a];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70528
#include <stdio.h>
#include <stdlib.h>

int main(){
    long N,A;
    long syain[200010] = {0},i;

    scanf("%ld", &N);

    for (i = 0; i < N - 1; i++){
        scanf("%ld", &A);
        syain[A - 1]++;
    }

    for (i = 0; i < N; i++)
    {
        printf("%ld\n", syain[i]);
    }
    return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,t;
    scanf("%d %d %d",&n,&x,&t);
    if(n%x==0){
        printf("%d",t*(n/x));
    }else{
        printf("%d",t*((n/x)+1));
    }
    return 0;    
}

Measured memory_bytes: 3808
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;  cin >> a >> b;
    bool ans = true;
    string s;  cin >> s;
    int i;
    rep(i, a) {
      if (!(s[i] >= '0' && s[i] <= '9')) ans = false;
    }
    if (s[a] != '-') ans = false ;
    for (i = a + 1; i < s.size(); ++i) {
      if (!(s[i] >= '0' && s[i] <= '9')) ans = false;
    }
    if (ans) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


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

P = []

for i in range(N):
    x,y = map(int,input().split())
    P.append((x,y))

mp = {}

for i in range(N):
    for j in range(i+1,N):
        mp[(P[i][0]-P[j][0],P[i][1]-P[j][1])] = 0
        mp[(P[j][0]-P[i][0],P[j][1]-P[i][1])] = 0

for i in range(N):
    for j in range(i+1,N):
        mp[(P[i][0]-P[j][0],P[i][1]-P[j][1])] += 1
        mp[(P[j][0]-P[i][0],P[j][1]-P[i][1])] += 1

ans = N
for i in mp:
    ans = min(ans,N-mp[i])

print(ans)

Measured memory_bytes: 9284
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#include <tuple>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000; //10^18
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}



int main(void) {

  string t;
  cin >> t;
  rep(i, t.size()) if (t[i] == '?') t[i] = 'D';
  cout << t << endl;
}


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

int main() {
    string S;cin>>S;
    int l = 0, r = S.size() - 1, ans = 0;
    while(l < r){
        if(S[l] == S[r]) ++l, --r;
        else if(S[l]=='x') ++ans, ++l;
        else if(S[r]=='x') ++ans, --r;
        else {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;

int dp[500][500];//dp[i][j]:i人目までにj個配った時のそれ
//dp[i+1][j]+=dp[i][j-k]*pw(sum(i),k)
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}

int w[500][500];//w[i][j];0^j~i^jまでの総和

int f(int a,int b,int k){//a^k~b^kまでの和
  int res=w[b][k]-w[a-1][k];
  if(res<0)res+=MOD;
  return res;
}

signed main(){
  int N,C;cin>>N>>C;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  dp[0][0]=1;
  for(int i=1;i<500;i++)
    for(int j=0;j<500;j++)
      w[i][j]=(w[i-1][j]+pw(i,j))%MOD;
  for(int i=0;i<N;i++){
    for(int j=0;j<=C;j++){
      for(int k=0;k<=j;k++){
        dp[i+1][j]+=dp[i][j-k]*f(a[i],b[i],k)%MOD;
        dp[i+1][j]%=MOD;
      }
    }
  }
  cout<<dp[N][C]<<endl;
}


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

typedef struct Tag
{
	string name;
	int x1, y1, x2, y2;
	vector<Tag> child;
} Tag;

string start_tag(const string& s, int& p)
{
	string name = "";
	++p;
	while (s[p] != '>')
		name += s[p++];
	++p;
	return name;
}

void tag_value(const string&s, int& p, Tag& tag)
{
	tag.x1 = tag.y1 = tag.x2 = tag.y2 = 0;

	while (s[p] != ',') {
		tag.x1 *= 10;
		tag.x1 += s[p++] - '0';
	}
	++p;

	while (s[p] != ',') {
		tag.y1 *= 10;
		tag.y1 += s[p++] - '0';
	}
	++p;

	while (s[p] != ',') {
		tag.x2 *= 10;
		tag.x2 += s[p++] - '0';
	}
	++p;

	while (s[p] != '<') {
		tag.y2 *= 10;
		tag.y2 += s[p++] - '0';
	}
}

Tag tag(const string& s, int& p)
{
	Tag node;
	node.name = start_tag(s, p);
	tag_value(s, p, node);
	while (s[p+1] != '/')
		node.child.push_back(tag(s, p));
	while (s[p] != '>')
		++p;
	++p;
	return node;
}

bool solve(int x, int y, const Tag& root)
{
	bool found = false;
	if (root.x1 <= x && x <= root.x2 && root.y1 <= y && y <= root.y2) {
		for (unsigned int i = 0; i < root.child.size(); ++i)
			found |= solve(x, y, root.child[i]);
		if (!found) {
			cout << root.name << " " << root.child.size() << endl;
			found = true;
		}
	}
	return found;
}

int main()
{
	int n;
	while (cin >> n) {
		if (n == 0)
			break;

		string s;
		cin >> s;
		int p = 0;

		Tag root = tag(s, p);
		for (int i = 0; i < n; ++i) {
			int x, y;
			cin >> x >> y;
			if (!solve(x, y, root))
				cout << "OUT OF MAIN PANEL 1" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 0
# AOJ 1209: Square Coins
#Python3 2018.7.19 bal4u
 
dp = [1]*300
for i in range(2, 18):
    for j in range(i**2, 300): dp[j] += dp[j-i**2]
 
while True:
    n = int(input())
    if n == 0: break
    print(dp[n])


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vi a(n); cin >> a;

    int x1=0,x2=0;

    rep(i,n){
        x1 ^= a[i];
        x2 ^= a[i];
        x2 ^= a[i];
    }

    if(x1 == x2) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

long long n;

void dfs(string s, int &res) {
  if (stoll(s) > n) return;
  int three = 0;
  int five = 0;
  int seven = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '3') three++;
    if (s.at(i) == '5') five++;
    if (s.at(i) == '7') seven++;
  }
  if (three >= 1 && five >= 1 && seven >= 1) res++;

  dfs(s + '3', res);
  dfs(s + '5', res);
  dfs(s + '7', res);
}

int main() {
  cin >> n;
  int ans = 0;
  dfs("0", ans);
  cout << ans;
}

Measured memory_bytes: 256
// 何これ
// ほんとにわかりません

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll x,k;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d<k) {
        k-=x/d;
        ll ans = x%d;
        if(k%2==0){
            cout<<ans<<endl;
        }else{
            cout<<abs(ans-d)<<endl;
        }
    }
    else{
        cout<<abs(x-k*d)<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 3540
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static char[] input;
    public static void main(String[] args) {
        while(read()){
            solve();
        }

    }

    static boolean read(){
        if(!sc.hasNext())return false;
        input = sc.next().toCharArray();
        return true;
    }

    static void solve(){
        StringBuffer sb = new StringBuffer();
        int index = 0;
        while( index < input.length){
            if(input[index] == '@'){
                int count = input[++index] - '0';
                index++;
                for(int i = 0; i < count; i++){
                    sb.append(input[index]);
                }
            }else{
                sb.append(input[index]);
            }
            index++;
        }
        System.out.println(sb);
    }

}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));

  ll ans = 0;
  REP(i, n) {
    if (i < n / 2) {
      ans -= 2 * a[i];
    } else {
      ans += 2 * a[i];
    }
  }

  if (n % 2 == 0) {
    ans += a[n / 2 - 1];
    ans -= a[n / 2];
  } else {
    ll tmp1 = ans, tmp2 = ans;

    tmp1 += a[n / 2 - 1];
    tmp1 -= 3 * a[n / 2];

    tmp2 -= a[n / 2];
    tmp2 -= a[n / 2 + 1];

    ans = max(tmp1, tmp2);
  }

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

Measured memory_bytes: 1152
n=input()
num=len(n)-1

for i in range(2**num):
    l=['-']*num
    for j in range(num):
        if (i >> j) & 1:
            l[num-1-j]="+"

    formula=""
    for l_num, l_m in zip(n,l+[""]):
        formula += l_num + l_m
    
    if eval(formula)==7:
        print(formula+"=7")
        break

Measured memory_bytes: 3064
// 2020-08-23 16:55:45
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll h, w, n;
  cin >> h >> w >> n;
  set<ll> topleft;
  unordered_set<ll> black;
  auto add = [&](ll a, ll b) {
    black.insert(a * w + b);
    rep(i, 3) rep(j, 3) {
      ll na = max(0ll, a-i);
      ll nb = max(0ll, b-j);
      topleft.insert(na * w + nb);
    }
  };
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    add(a, b);
  }
  vector<ll> ans(10, 0);
  for(const ll c : topleft) {
    ll a = c / w, b = c % w;
    if(h <= a + 2 || w <= b + 2) continue;
    ll cnt = 0;
    rep(i, 3) rep(j, 3) {
      ll na = a + i;
      ll nb = b + j;
      cnt += black.count(na * w + nb) > 0;
    }
    ans[cnt]++;
  }
  ll ans0 = (h - 2) * (w - 2);
  REPC(i, 1, 9) ans0 -= ans[i];
  ans[0] = ans0;
  rep(i, 10) cout << ans[i] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 49372
/*
Powered by 0736TuT
Code + Music + Games = Life
*/

#include<iostream>
#include<cstdio>
#define MAXN 100010

typedef long long qwq;

using namespace std;

qwq scan(qwq *buf_tar)
{
    char buf_c=0; bool is_rev=0;
    while(buf_c!='-'&&(buf_c<'0'||buf_c>'9')) {buf_c=getchar(); if(buf_c==EOF) return EOF;}
    if(buf_c=='-') is_rev=1,buf_c=getchar();
    *buf_tar=0;
    while(buf_c>='0'&&buf_c<='9') {*buf_tar*=10; *buf_tar+=buf_c-'0'; buf_c=getchar();}
    if(is_rev) *buf_tar=-*buf_tar;
    return 0;
}

qwq n;
qwq num[MAXN];
qwq f[MAXN],mi[MAXN];

inline qwq bsearch(const qwq,const qwq,const qwq);

int main()
{
    qwq temp;
    scan(&n);
    for(qwq i=1;i<=n;i++) {scan(&num[i]); mi[i]=0x7fffffff;}
    f[1]=1; mi[1]=num[1];
    for(qwq i=2;i<=n;i++)
    {
	temp=bsearch(1,i-1,num[i]);
	mi[temp+1]=num[i];
	f[i]=temp+1;
    }
    for(qwq i=1;i<=n+1;i++) f[i]=max(f[i],f[i-1]);
    printf("%lld\n",f[n]);
    return 0;
}

inline qwq bsearch(const qwq l,const qwq r,const qwq s)
{
    if(l==r)
    {
	if(mi[l]<s) return l;
	return l-1;
    }
    qwq mid=(l+r)>>1;
    if(mi[mid]<s&&mi[mid+1]>s) return mid;
    if(mi[mid]>=s) return bsearch(l,mid,s);
    return bsearch(mid+1,r,s);
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

int main() {
	string s;
	cin >> s;
	string buf = "";
	for (char c : s) {
		if (c == 'B') {
			if (!buf.empty())
				buf.erase(buf.end() - 1);
		} else
			buf += c;
	}
	cout << buf << endl;
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  bool flag = true;
  cin >> N;
  vector<int> A(N);
  rep(i, N)
    cin >> A[i];
  rep(i, N) {
    if (A[i] % 2 == 0) {
      if (A[i] % 3 != 0 && A[i] % 5 != 0) {
        flag = false;
        cout << "DENIED" << endl;
        break;
      }
    }
  }
  if (flag)
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x, y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)
using namespace std;
int k;
ll ans;
int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    cin >> k;
    for(int i=1; i<=k; ++i)
        for(int j=1; j<=k; ++j)
            for(int x=1; x<=k; ++x)
            {
                ans += __gcd(i,__gcd(j,x));
            }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3660
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE ,University of Asia Pacific
Todo:
https://codeforces.com/contest/920/problem/F
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

typedef long long ll;
const int N=2e5+5;
int q,k,m,n,cs=1;

void HalfDead()
{
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      ll res=a*c;
      res=max(res,a*d);
      res=max(res,b*c);
      res=max(res,b*d);
      cout<<res<<endl; 
} // func

int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);  cout.tie(0);
      // cout<<setprecision(10)<<fixed;
      int tc=1;
     // cin>>tc;
      while(tc--)
      {   
            HalfDead();
      }
      return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  for (ll i = 1; i * x <= y; i <<= 1) {
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e4+7;
const double eps=1e-8;
const LL inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string s;
string ss="CODEFESTIVAL2016";
int main() {
	int n;
	cin>>s;
	int ans=0;
	for(int i=0;i<16;i++){
        if(s[i]!=ss[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    string O, E;
    cin >> O >> E;
    rep(i, 0, E.size()){
        cout << O[i] << E[i];
    }
    if(O.size() > E.size()) cout << O[O.size()-1];
    cout << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> data(N, vector<int>(3));

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


Measured memory_bytes: 5760
import itertools

N, M = map(int, input().split())
K = []
A = []
for _ in range(N):
    k, *a = map(int, input().split())
    K.append(k)
    A.append(a)

A = [x-1 for x in list(itertools.chain.from_iterable(A))]

ans = 0
for i in range(M):
    if A.count(i) == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
 


    
    int num;
    
    cin >> num;
    
    int a[num];
    
    for(int i=0; i<num; i++)
        cin >> a[i];

    int ans=0;
    
 //   cout << (a[0]%2) << endl;
    
    bool flg = true;
    
    while(1){
        for(int i=0; i<num; i++){
            if((a[i]%2) == 0){
                a[i] = a[i]/2;
            }else{
              
                flg = false;
                break;
            }
        }
        
        if(flg){
            ans++;
        }else{
            cout << ans << endl;  
            break;
        }
    }
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const long long  mod = 1e9+7;
map<long long ,long long>dp;
long long Dp(long long x)
{
    if(dp[x])return dp[x];
    else
    {
        return dp[x] = ((Dp(x/2)+Dp((x-1)/2)+Dp((x-2)/2)) )%mod;
    }
}
int main()
{
    dp[0] = 1;
    dp[1] = 2;
    long long n;
    cin>>n;
    cout<<Dp(n);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>

using namespace std;

int m,n;
int num[60],num2[60];
string s[18]={"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
int main(void){
	while(1){
		scanf("%d%d",&m,&n);
		if(m==0)break;
		memset(num,0,sizeof(num));
		memset(num2,0,sizeof(num2));
		num[0]=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<50;j++)num2[j]=num[j]*m;
			for(int j=0;j<50;j++){
				num2[j+1]+=num2[j]/10000;
				num2[j]=num2[j]%10000;
			}
			for(int j=0;j<50;j++)num[j]=num2[j];
			memset(num2,0,sizeof(num2));
		}
		for(int i=17;i>=0;i--){
			if(num[i]!=0){
				printf("%d",num[i]);
				cout << s[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
<?php
  fscanf(STDIN,"%d %d %d",$a, $b, $k);
  if($b-$a < $k*2){
    for($i=$a; $i<=$b; $i++){
      echo $i."\n";
    }
  }else{
    for($i=$a; $i<$a+$k; $i++){
      echo $i."\n";
    }
    for($i=$b-($k-1); $i<=$b; $i++){
      echo $i."\n";
    }
  }
  
 

Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    long long x;
    cin >> x;
    long long a, b=-100;
    for(a=1;;a++){
        if(a*a*a*a*a*2<x)continue;
        for(;b<a;b++){
            long long ab = a*a*a*a*a-b*b*b*b*b;
            if(ab==x){
                cout << a << " " << b << endl;
                return 0;
            }else if(ab < x){
                b--;
                break;
            }
        }
    }
    return 0;
}

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

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

int main(){
	ll N; cin>>N;
	ll ans=1;
	rep(i,N) ans*=3;
	ll tmp=1;
	rep(i,N){
		ll x; cin>>x;
		if(x%2==0) tmp*=2;
	}
	cout<<ans-tmp;
}

Measured memory_bytes: 256