akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int count=0;
  int a[2]={0,999999};
  int N,M;
  cin>>N>>M;
  int A[1000000][2];
  rep(i,M){
    rep(j,2){
  cin>>A[i][j];
    }
  }
  rep(i,M){
    if(A[i][0]>a[0]){
      a[0]=A[i][0];
    }
  }
  rep(i,M){
    if(A[i][1]<a[1]){
      a[1]=A[i][1];
    }
  }
  if(0>a[1]-a[0]){
    cout<<0;
    return 0;
  }
  cout<<a[1]-a[0]+1;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
 
using namespace std;
 
using ll = long long int; 
 
void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;
 
    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}
 
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}
 
ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}
 
const int MAX = 50;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
int main(void){
 
    char x;
    cin>>x;
    char y = ++x;
 
    cout<<y<<endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
   
   map<int,bool> m;
   ll count=0;
   int now = 0;
   while(1){
       count++;
       if(m[now]){
           cout<<-1<<endl;
           return 0;
       }else
       m[now] = true;
       now = a[now] - 1;
       if(now == 1){
           cout<<count<<endl;
           return 0;
       }
   }
    
    return 0;
}


Measured memory_bytes: 8464
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
ll a,b,c,i,j,k,n,m;

struct node{
	ll x,y;
};

int main(){
	scanf("%lld",&n);
	scanf("%lld%lld",&a,&b);

	if(abs(a-b)%2==0)
		printf("%lld",abs(a-b)/2);
	else
	{
		c=max(a,b);
		a=min(a,b);
		b=c;
		if(n-a<b-1){
			c=n-b;
			c++;
			b=n;
			a=a+c;
			c=c+(b-a)/2;
		}
		else
        {
            c=a-1;
            c++;
            a=1;
            b=b-c;
            c=c+(b-a)/2;
        }
        printf("%lld",c);

	}
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n, m = map(int, sys.stdin.readline().split())
matrix_a = list()
matrix_b = list()

for i in range(n):
    matrix_a.append(list(map(int, sys.stdin.readline().split())))

for i in range(m):
    matrix_b.append(int(sys.stdin.readline()))

#print(matrix_a)
#print(matrix_b)

for i in range(n):
    product = 0
    for x in range(m):
        product += matrix_a[i][x]*matrix_b[x]
    print(product)



Measured memory_bytes: 6016
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    if (N == 1) {
      cout << "Hello World" << endl;
    } else {
      int A, B;
      cin >> A >> B;
      cout << (A + B) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import groupby
s = input()
c = [0] * len(s)
a = [[k, len(list(g))] for k, g in groupby(s)]
p = 0
for i in range(len(a)):
	if i%2 == 1:
		continue
	else:
		b = a[i][1]+a[i+1][1]
		if b%2 == 0:
			c[p + a[i][1] - 1] = b//2
			c[p + a[i][1]] = b//2
		else:
			if a[i][1]%2 == 0:
				c[p + a[i][1] - 1] = b//2
				c[p + a[i][1]] = b//2 + 1
			else:
				c[p + a[i][1] - 1] = b//2 + 1
				c[p + a[i][1]] = b//2
		p += b
print(' '.join(map(str, c)))

Measured memory_bytes: 21280
import java.util.HashMap;
import java.util.Objects;
import java.util.Scanner;

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

    long N = scanner.nextLong();
    int M = 1_000_000_007;

    int n = 0;
    long t = N;
    while (t > 0) {
      n++;
      t >>= 1;
    }

    System.out.println(rec(n, N, M, new HashMap<>()));
  }

  private static long rec(int i, long j, long mod, HashMap<Pair, Long> memo) {
    if (j < 0) return 0;
    if (i <= 0) return 1;
    if ((1L << (i + 1)) - 2 < j) return rec(i, (1L << (i + 1)) - 2, mod, memo);
    Pair key = new Pair(i, j);
    if (memo.containsKey(key)) return memo.get(key);
    long res = rec(i - 1, j, mod, memo);
    res += rec(i - 1, j - (1L << (i - 1)), mod,memo);
    res %= mod;
    res += rec(i - 1, j - (1L << i), mod, memo);
    res %= mod;
    memo.put(key, res);
    return res;
  }

  private static class Pair {
    public final int i;
    public final long j;

    private Pair(int i, long j) {
      this.i = i;
      this.j = j;
    }

    @Override public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Pair pair = (Pair) o;
      return i == pair.i &&
          j == pair.j;
    }

    @Override public int hashCode() {
      return Objects.hash(i, j);
    }
  }
}


Measured memory_bytes: 23892
import sys

def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    il = [str(i) for i in range(0, 10)]
    a, b = list(map(int, input().rstrip('\n').split()))
    s = str(input().rstrip('\n'))
    for i, v in enumerate(s):
        if i < a or a < i < a + b + 1:
            if v not in il:
                print("No")
                exit()
        elif i == a:
            if v != "-":
                print("No")
                exit()
    print("Yes")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
#define MAX_N (int)1e7
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll b;
    while(cin >> b, b)
    {
        ll pos = 1, num = INF, ans1, ans2;
        while(1)
        {
            if(pos >= b) break;
            ll x = pos * (pos + 1) / 2;
            if(b < x) break;
            ll d = b - x;
            if(d % pos == 0)
            {
                ans1 = d / pos + 1;
                ans2 = pos;
            }
            pos++;
        }
        cout << ans1 << " " << ans2 << endl;
    }
	return 0;
}


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


int main(void)
{
	int n;
	cin >> n;
	int d[100];
	for (int i = 0; i < 100; i++)
		d[i] = 0;
	for (int i = 0; i < n; i++) {
		int m;
		cin >> m;
		d[m-1]++;
	}

	int count = 0;
	for (int i = 0; i < 100; i++) {
		if (d[i] != 0)
			count++;
	}

	cout << count << endl;

	return 0;
}


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

clock_t present = clock();
void complexiti(){
	present = clock() - present;
	cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';
}

void solver(){
	//~ type your code here
	int N;
	cin >> N;
	double ans = 0.0;
	for(int i = 0 ; i < N ; ++i){
		double d;
		cin >> d;
		ans += 1.0/d;
	}
	ans = 1.0/ans;
	cout << setprecision(10) << ans << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 205

const int INF = 1e9+7;

double dp[ARRAY_MAX][ARRAY_MAX];

int main(){

    int n;
    cin >> n;
    vector<int> t(n),v(n);
    for(int i = 0;i < n;i++){
        cin >> t[i];
    }
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    dp[0][0] = 1;
    for(int number = 0;number < n;number++){//i番目までで
        for(int v_now = 0;v_now <= 105;v_now++){//現在の速さがjの時
            if(v_now > v[number] || dp[number][v_now] == 0){
                continue;
            }
            for(int v_next = 0;v_next <= 105;v_next++){

                if(v_next > v[number]){
                    continue;
                }
                int a = v[number] - v_now;//加速時間
                int b = v[number] - v_next;//減速時間
                if(t[number] < abs(v_now - v_next)){
                    //遷移できない(加減速が間に合わない)
                    continue;                
                }else if(a + b <= t[number]){
                    double up = 1.0*(v[number] *v[number] - v_now * v_now)/2;//加速中
                    double stay = v[number] *(t[number] - a - b);//限界速度で走行
                    double down = 1.0 * (v[number] * v[number] - v_next * v_next)/2;//減速中
                    double len = up + stay + down;//距離の合計
                    dp[number+1][v_next] = max(dp[number+1][v_next],dp[number][v_now] + len);
                
                }else{
                    double x = 1.0 * (t[number] + v_next - v_now)/2;//加速時間
                    double y = 1.0 * (t[number] - v_next + v_now)/2;//減速時間
                    double top = v_now + x;//最高速度


                    double up = 1.0 * (top * top - v_now * v_now)/2;//加速
                    double down = 1.0 *(top * top - v_next * v_next)/2;//減速(台形の面積)
                    double len = up + down;//距離の合計

                    dp[number+1][v_next] = max(dp[number+1][v_next],dp[number][v_now] + len);
                }
            }
        }
    }
    printf("%.9f\n",dp[n][0]-1);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;


ll N,M;
ll x[100100],y[100100];
ll xx[100100],yy[100100];
ll sum_x,sum_y;
int main(){
  cin >> N>> M;
  rep(i,N){
    cin >> x[i];
    if(i!=0){
      xx[i] = x[i]-x[i-1];
      cerr << xx[i] << " " << (N-i)*i << endl;
      xx[i] = (xx[i] * (N-i))%MOD;
      xx[i] = (xx[i] * i)%MOD;
      sum_x = (xx[i] + sum_x) % MOD;
    }
  }
  rep(i,M){
    cin >> y[i];
    if(i!=0){
      yy[i] = y[i]-y[i-1];
      yy[i] = (yy[i] * (M-i))%MOD;
      yy[i] = (yy[i] * i)%MOD;
      sum_y = (yy[i] + sum_y) % MOD;
    }
  }
  ll ans = (sum_x*sum_y) % MOD;
  cout << ans << endl;
}


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

int main(){
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += v[i] * v[j] ;
        }
    }
    cout << ans << endl;

    return 0 ;
}

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

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

	string A;
	for (int i = 0; i < S.size(); i++)
	{
		switch (S[i])
		{
		case '0':A.push_back('0'); break;
		case '1':A.push_back('1'); break;
		case 'B':if (A.size() > 0) { 
			A.pop_back();
		}; break;
		}
	}

	cout << A << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int m,n;
  cin >> m >> n;
  
  vector<vector<string>>word(m,vector<string>(n));
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      cin >> word[i][j];
    }
  }
  
  int a;
  char b;
  
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(word[i][j] == "snuke"){
        a = i + 1;
        b = char(j + 'A');
      }
    }
  }
  
  cout << b << a << endl;
  
  return 0;
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  int ans = 0;
  for(int i=0; i<N-1; i++){
    if(S[i] == S[i+1]){
      ans++;
    }
  }
  ans = min(ans + 2*K, N-1);
  
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int A,B,C,X,Y;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&X);
  scanf("%d",&Y);
  int a=0;
  int b=0;
  int c=0;
  int min = A*X + B*Y;
  a = X;
  b = Y;
  while(c<2*X || c<2*Y){
    if(a>0){
    a--;
    }
    if(b>0){
    b--;
    }
    c += 2;
    
    
    int x = a*A + b*B + c*C;
    if(x<min){
      min = x;
    }
  }
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
string s,t;
  bool flag = true;
  cin>>s>>t;
  for(int i = 0 ; i<=t.length()-2;i++)
    if(s[i]!=t[i])
      flag=false;
  if(t.length()<=s.length())
    flag=false;
  if(flag)
    cout<<"Yes\n";
  else
    cout<<"No\n";
 
}


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

int gcd(int x,int y)
{
  if(y>x) return gcd(y,x);
  if(y==0) return(x);
  /* x>=y??????y!=0 */
  return gcd(y,x%y);
}

int main()
{
  int x,y,z;
  scanf("%d %d",&x,&y);
  z=gcd(x,y);
  printf("%d\n",z);
  return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define INF 1000000000

using namespace std;

int h=0,n=0;
int a[1001];
int b[1001];
int dp[1001][20001];

int main()
{
	cin >> h >> n;
	for (int i=1; i<=n; i++)
	{
		cin >> a[i] >> b[i];
	}	
	for (int i=0; i<=n; i++)
		for (int j=0; j<=h+10000; j++)
			dp[i][j] = INF;
	dp[0][0] = 0;
	int Min = INT_MAX;
	for (int i=1; i<=n; i++)
	{
		for (int j=0; j<=h+10000; j++)
		{
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
			if (j-a[i]>=0){
				dp[i][j] = min(dp[i][j], dp[i-1][j-a[i]]+b[i]);
				dp[i][j] = min(dp[i][j], dp[i][j-a[i]]+b[i]);
			}
		}
	}	
	for (int i=1; i<=n; i++)
	{
		for (int j=h; j<=h+10000; j++)
			Min = min(Min, dp[i][j]);
	}
	cout << Min;
	return 0;
}


Measured memory_bytes: 78464
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n, LL p) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,p;cin>>n>>p;
    string s;cin>>s;
    REP(i,n){
        s[i] -= '0';
    }

    LL result = 0;

    if(p==2 || p==5){
        REP(i,n){
            if(s[i]%p==0){
                result += i+1;
            }
        }
        cout<<result<<endl;
        return;
    }

    REV(s);
    VL d(n);
    d[0] = s[0]%p;
    FOR(i,1,n){
        d[i] = d[i-1] + s[i]*modpow(10,i,p);
        d[i]%=p;
    }

    VL c(p);
    c[0]++;
    REP(i,n){
        c[d[i]]++;
    }

    REP(i,p){
        result += c[i]*(c[i]-1)/2;
    }
    
    cout<<result<<endl;




	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main(){
	long n;
	cin >> n;
	vector<long> a;
	a.resize(n);
	for (long i = 0; i < n; i++){
		cin >> a[i];
	}
	for (long i = 0; i < n; i++){
		cout << a[n - i - 1];
		if (i < n - 1){
			cout << " ";
		}
	}
	cout << endl;
}

Measured memory_bytes: 1196
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      h: usize,
      w: usize,
      n: usize,
      aa: [usize; n],
    }

    let mut grid = vec![vec![0; w]; h];
    let mut x = 0;
    let mut y = 0;
    let mut right = true;
    for i in 0..n {
        let number = i+1;
        let a = aa[i];

        for _ in 0..a {
            grid[x][y] = number;

            if right {
                y += 1;
                if y == w {
                    right = false;
                    y = w-1;
                    x += 1;
                }
            } else {
                if y == 0 {
                    right = true;
                    y = 0;
                    x += 1;
                } else {
                    y -= 1;
                }
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            if j == 0 {
                print!("{}", grid[i][j]);
            } else {
                print!(" {}", grid[i][j]);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 4352
/* ITP1_9_A:Finding a Word */
/* 20181124 */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define N 11
#define M 1001

int main(void) {
	char W[N];
	char T[M];
	int cnt = 0;
	int i;

	scanf("%s", W);
	while(1) {
		scanf("%s", T);
		if(strcmp(T, "END_OF_TEXT") == 0) break;
		for(i = 0; T[i]; i++) T[i] = tolower(T[i]);
		if(strcmp(T, W) == 0) cnt++;
	}

	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  bool f=true,e=false,o=false,ff=true;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int d=M;
  for(int i=1;i<n;i++){
    if(a[i]!=a[0]) ff=false;
    if(a[i]%a[0]!=0) f=false;
    d=min(d,gcd(a[0],a[i]));
   }
 cout<<d;
}
    

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

#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int INF = 2e9;
const int mod = 1e9 + 7;
const int N = 1010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main(void)
{
    int w,h,x,y; cin >> w >> h >> x >> y;
    cout << (double)w * h / 2;
    if (x * 2 == w && y * 2 == h) cout << " 1" << endl;
    else cout << " 0" << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a[111111],l,r,mid;
ll f(ll x)
{
	ll ans=a[x];
	for(ll i=1;i<=n;i++)
	{
		if(i==x)
			continue;
		if(2*ans<a[i])
			return 0;
		ans+=a[i];
	}
	return 1;
}
int main()
{
	cin>>n;
	for(ll i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	l=1,r=n;
	sort(a+1,a+n+1);
	while(l<r)
	{
		mid=(l+r)/2;
		if(f(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<n-l+1;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
 
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9;

pair<int, int> b[N];
int n, m, a[N], p[N], size[N * 4];
ll ans1 = -1e18, ans[N], sum[N], s[N * 4];

void ins(int k, int l, int r, int p, int v) {
	if (l == r) {
		size[k]++;
		s[k] += v;
		return;
	}
	int mid = l + r >> 1;
	if (p >= mid + 1) ins(k << 1 | 1, mid + 1, r, p, v);
	else ins(k << 1, l, mid, p, v);
	s[k] = s[k << 1] + s[k << 1 | 1];
	size[k] = size[k << 1] + size[k << 1 | 1];
}

ll ask(int k, int l, int r, int p) { 
	if (p <= 0) return 0;
	if (size[k] <= p) return s[k];
	int mid = l + r >> 1;
	return ask(k << 1, l, mid, p) + ask(k << 1 | 1, mid + 1, r, p - size[k << 1]);
}

ll ask1(int k, int l, int r, int p) {
	if (p <= 0) return 0;
	if (size[k] <= p) return s[k];
	int mid = l + r >> 1;
	return ask1(k << 1 | 1, mid + 1, r, p) + ask1(k << 1, l, mid, p - size[k << 1 | 1]);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 3 * n; i++) {
		scanf("%d", a + i);
		sum[i] = sum[i - 1] + a[i];
		b[i] = mk(a[i], i);	
	}
	sort(b + 1, b + 1 + 3 * n);
	for (int i = 1; i <= 3 * n; i++) p[b[i].second] = i;
	ll tmp = 0;
	for (int i = 1; i <= 2 * n; i++) { 
		ins(1, 1, 3 * n, p[i], a[i]);  
		if (i >= n) {
			ans[i] += sum[i];
			ans[i] -= ask(1, 1, 3 * n, i - n);
		}
	}
	memset(size, 0, sizeof(size));
	memset(s, 0, sizeof(s));
	for (int i = 3 * n; i >= n; i--) {
		if (i <= 2 * n) {
			ans[i] -= sum[3 * n] - sum[i];
			ans[i] += ask1(1, 1, 3 * n, n - (i - n)); 
			ans1 = max(ans1, ans[i]);
		}
		ins(1, 1, 3 * n, p[i], a[i]);
	}
	cout << ans1;
}

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

int main() {
    string S;
    long long K; cin >> S >> K;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == '1' && K != 1) {
            K--;
        } else {
            cout << S.at(i) << endl;
            return 0;
        }
    }
}

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

bool check(int i) {
    string t = "";
    if (s[i] == 'e') {
        for (int j = i; j < min(i + 5, (int)s.size()); j++) t += s[j];
        return t == "erase";
    } else if (s[i] == 'd') {
        for (int j = i; j < min(i + 5, (int)s.size()); j++) t += s[j];
        return t == "dream";
    }
    return false;
}

int main() {
    cin >> s;
    int i = 0;
    while (i < s.size()) {
        if (!check(i)) break;
        if (check(i)) i += 5;
        if (i >= s.size()) break;
        if (s[i - 5] == 'e' && s[i] == 'r') i++;
        else if (s[i - 5] == 'd' && i + 1 < s.size() && s[i] == 'e' && s[i + 1] == 'r') {
            i += 2;
            if (i >= s.size()) break;
            if (s[i] == 'a') i -= 2;
        }
    }
    if (i >= s.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 640
def test():

	str = input()
	n = int(input())

	for i in range(n):

		operation = input().split()

		a = int(operation[1])
		b = int(operation[2])

		if operation[0] == "print":
			print(str[a:b+1])

		elif operation[0] == "reverse":
			if a != 0:
				str = str[0:a] + str[b:a-1:-1] + str[b+1:len(str)]
			else:
				str = str[b::-1] + str[b+1:len(str)]

		elif operation[0] == "replace":
			p = operation[3]
			str = str[0:a] + p + str[b+1:len(str)]


if __name__ == "__main__":
	test()


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
 #define ll long long
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll mx= max(a,b)*max(c,d);
    ll mx1= max(a,b)*min(c,d);
    ll mx2=min(a,b)*max(c,d);
    ll mx3=min(a,b)* min(c,d);
    cout<<max(mx3,max(mx,max(mx1,mx2)));

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int lowbit(int x) { return (x & -x); }

const int N = 1e5 + 5;

int n;
ll k; 
int a[N], cnt[N << 1], pre[N << 1];

int pl(int x, int y) { return x > y ? -1 : 1; }

void update(int x) {
	while(x <= (N << 1)) {
		++cnt[x];
		x += lowbit(x);	
	}
}

int query(int x) {
	int ret = 0;
	while(x) {
		ret += cnt[x];
		x -= lowbit(x);
	}
	return ret;
}

bool check(int x) {
	memset(cnt, 0, sizeof cnt);
	memset(pre, 0, sizeof pre);
	for(int i = 1; i <= n; i++) pre[i] = pre[i - 1] + pl(a[i], x);
	for(int i = 0; i <= n; i++) pre[i] += n + 1;
	ll sum = 0;
	for(int i = 0; i <= n; i++) {
		sum += query(pre[i] - 1);
		update(pre[i]);
	}
	return (sum >= k);
}

int main() {
	cin >> n;
	k = 1ll * n * (n + 1) / 4 + 1;
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	int l = 1, r = 1e9;
	while(l < r) {
		int mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1; 
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 5576
// *** creator : cfmasterr *** //
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
  	cin >> a[i];
  	sum += a[i];
	}
	for(int i = 0; i < n; i++) {
		ans += (a[i] * (sum - a[i]));
	}
	cout << ans  / 2 << '\n';
  return 0;
}



Measured memory_bytes: 256
s = int(input())
if(s<3):
    print(0)
    exit()

l = s//3
cnt = 0
mod = 10**9+7
for i in range(l):
    if(i==0):
        cnt += 1
        continue

    remain = s-3*(i+1)
    bar_remain = remain+i
    n = 1
    for j in range(i):
        n*=(bar_remain-j)

    k = 1
    for j in range(1,i+1):
        k*=j

    cnt += (n//k)%mod
    cnt %= mod

print(cnt)

Measured memory_bytes: 9200
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int x, y;

int main(){
	scanf("%d", &x);
	long long n = 2 * x; 
	for(int i = 1; i <= 1e5; i++)
		if(i * (i + 1) >= n){
			y = i;
			break;
		}
	printf("%d", y);
}

		

Measured memory_bytes: 128
import sys
DBG =  not True
ex = 42

def h(x,i):
    y = x % (2**(i+1))
    if i == 0:
        y = x % 4
        ret = 1 if y==1 or y==2 else 0
    elif y < 2**i:
        ret = 0
    else:
        ret = 1 - (y - 2**i)%2
    if DBG:
        print("h x {} i {} y {} ret {}".format(x,i,y,ret))
    return ret

def g(x):
    if x < 0:
        return 0
    sum = 0
    for i in range(ex):
        sum += h(x,i) << i
    if DBG:
        print("g x {} ret {}".format(x,sum))
    return sum

a,b = map(int, input().split())
print(g(b)^g(a-1))


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n, m, k;
  cin >> n >> m >> k;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      if(i * m + j * n - 2 * i * j == k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
	return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;



void solve() {
	cout << "square1001" << endl;
}

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



Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <vector>


using namespace std;

using hint32 = int32_t;
using hint64 = int64_t;
using huint32 = uint32_t;
using huint64 = uint64_t;
using hint = hint32;
using huint = huint32;


#define hrep( i, n )		for( hint i = 0; i < ( hint )( n ); ++i )
#define hrepr( i, n )		for( hint i = ( hint )( n ); i >= 0; --i)
#define hfor( i, a, n )		for( hint i = ( hint )( a ); i < ( hint )( n ); ++i )
#define hforr( i, a, n )	for( hint i = ( hint )( n ); i >= ( hint )( a ); --i)


#define all(x)	(x).begin(),(x).end()


#define dump(x)			std::cout << #x << " = " << x << "\n";
#define hout(x)			std::cout << x << "\n";
#define hout2(x,y)		std::cout << x << "," << y << "\n";
#define hout3(x,y,z)	std::cout << x << "," << y << "," << z << "\n";

#define ini	std::cin.tie(0);std::ios::sync_with_stdio(false)



int main()
{
	ini;

	hint n;
	string s;

	cin >> n >> s;

	map<char, hint> m,m2;
	hrep(i, n)
	{
		if (m.count(s[i]) == 0)m[s[i]] = 0;
		m[s[i]]++;
	}

	hint cnt = 0;
	hint res = 0;
	
	hrep(i, n)
	{
		res = max(res, cnt);
		--m[s[i]];
		if (m[s[i]] == 0)
		{
			if (m2.count(s[i])!=0)
				--cnt;
			continue;
		}
		if (m2.count(s[i]) != 0)continue;
		++cnt;
		m2[s[i]] = 1;
	}
	hout(res);
	return 0;
}


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

#define ll long long

ll bigmod(ll a, ll b, ll m)  {
	
	a %= m;
	ll res = 1;
	while(b > 0) {
		
		if(b & 1) {
			res = (res * a) % m;
		}
		a = (a * a) % m;
		b >>= 1;
	}
	return res;
}
int main() {
	// your code goes here
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> mp;
	for(auto& x : a) {
		cin >> x;
		mp[x]++;
	}
	
	if(n%2) {
		
		if(mp[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		
		mp.erase(0);
	}
	
	for(auto x : mp) {
		
		if(x.second  & 1) {
			
			cout << 0 << endl;
			return 0;
		}
	}
	
	cout << bigmod(2, n/2, 1e9+7) << endl;
	
	
	return 0;
}

Measured memory_bytes: 3584
// https://atcoder.jp/contests/abc122/tasks/abc122_d

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }
map<string, ll> mp;
// 文字列長、今までの文字列
ll rec(int n, string s) {
    static regex re(".*(A.?GC|AG.?C|GAC|ACG)");
    bool result = regex_match(s, re);
    if (result) {
        return 0;
    }
    if (n == 0) {
        // cout << s << endl;
        return 1;
    }
    ll ret = 0;
    //末尾から3桁の文字列 + ":" + 残り文字数
    int pos = max(0, (int)s.length() - 3);
    string ends = s.substr(pos) + ":" + to_string(n);
    if (mp.count(ends) == 0) {
        ret = rec(n - 1, s + "A") + rec(n - 1, s + "G") + rec(n - 1, s + "C") +
              rec(n - 1, s + "T");
        mp[ends] = ret;
    } else {
        ret = mp[ends];
    }
    return ret % MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    cout << rec(n, "") << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int hoge(vector<int> &ans, int x, int i, int v) { return x + ans[i - x * v]; }

int main() {
  vector<int> vec = {1};
  for (int i = 1; pow(6, i) <= 100000; ++i)
    vec.push_back(pow(6, i));
  for (int i = 1; pow(9, i) <= 100000; ++i)
    vec.push_back(pow(9, i));

  sort(vec.begin(), vec.end());

  vector<int> ans(100001, INT_MAX);
  ans[0] = 0;
  for (auto &v : vec) {
    for (int i = 1; i < 100001; ++i) {
      int x0 = 0;
      int x1 = i / v * 1 / 3;
      int x2 = i / v * 2 / 3;
      int x3 = i / v;
      int v0 = hoge(ans, x0, i, v);
      int v1 = hoge(ans, x1, i, v);
      int v2 = hoge(ans, x2, i, v);
      int v3 = hoge(ans, x3, i, v);
      while (3 < x3 - x0) {
        if (v1 <= v2 && v2 <= v3) {
          if (x1 - x0 < x2 - x1) {
            x3 = x2;
            x2 = (x1 + x2) / 2;
            v3 = v2;
            v2 = hoge(ans, x2, i, v);
          } else {
            x3 = x2;
            x2 = x1;
            x1 = (x0 + x1) / 2;
            v3 = v2;
            v2 = v1;
            v1 = hoge(ans, x1, i, v);
          }
        } else {
          if (x3 - x2 < x2 - x1) {
            x0 = x1;
            x1 = (x1 + x2) / 2;
            v0 = v1;
            v1 = hoge(ans, x1, i, v);
          } else {
            x0 = x1;
            x1 = x2;
            x2 = (x2 + x3) / 2;
            v0 = v1;
            v1 = v2;
            v2 = hoge(ans, x2, i, v);
          }
        }
      }
      ans[i] = min({v0, v1, v2, v3});
    }
  }

  int n;
  cin >> n;
  cout << ans[n] << endl;
}

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

using namespace std;

typedef long long int lli;

const lli MAX_N = 200000;

int main(int argc, char const *argv[]) {
  lli N;
  cin >> N;
  lli A[MAX_N], S[MAX_N+1];
  lli ans = 0;
  S[0] = 0;
  for (lli i = 0; i < N; i++) cin >> A[i];
  for (size_t i = 1; i < N+1; i++) S[i] = S[i-1] + A[i-1];
  sort(S, S + N+1);
  lli current = S[0];
  lli cnt = 1;
  vector<lli> cntvec;
  for (size_t i = 1; i < N+1; i++) {
    if (S[i] != current) {
      current = S[i];
      if (cnt != 1) cntvec.push_back(cnt);
      cnt = 1;
    }
    else cnt++;
  }
  if (cnt != 1) cntvec.push_back(cnt);
  for (size_t i = 0; i < cntvec.size(); i++) {
    ans += (cntvec[i] * (cntvec[i]-1))/2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
require 'complex'

N, D = gets.chomp.split(' ').map(&:to_i)
coos = N.times.map {
  gets.chomp.split(' ').map(&:to_i)
}
puts coos.combination(2).map { |a, b|
  Math.sqrt(a.zip(b).map { |y, z| (y - z)**2 }.reduce(:+))
}.select { |n|
  n - n.to_i == 0
}.size

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

using namespace std;
using ll = long long int;

int main() {
    static const double pi = 3.141592653589793;
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double rad =
        pi * 2 *
        ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

    double pow = (double)(a * a + b * b) - (double)(2 * a * b) * cos(abs(rad));

    // cout << sqrt(pow) << endl;
    printf("%20.20Lf\n", sqrtl(pow));
}

Measured memory_bytes: 4160
N = int(input())
H = list(map(int,input().split()))

dp = [float("inf") for i in range(N)]
dp[0] = 0

for i in range(N-1) :
    dp[i+1] = min(dp[i+1], dp[i] + abs(H[i] - H[i+1]))
    if i <= N-3 :
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i] - H[i+2]))

ans = dp[N-1]

print(ans)

Measured memory_bytes: 13980
#include <iostream>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
int z;
if(y%2==1)cout <<"No";
else
{
z=(4*x-y)/2;
if(z>=0 && x-z>=0)cout <<"Yes";
else cout <<"No";
}


    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define M 100005
typedef long long LL;
template<class T>void tomax(T &x,T y){
	if(x<y)x=y;	
}
template<class T>void tomin(T &x,T y){
	if(x>y)x=y;	
}
multiset<int>T;
multiset<int>::iterator it;
int A[M];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	T.insert(A[1]);
	int ans=1;
	for(int i=2;i<=n;i++){
		it=T.lower_bound(A[i]);
		if(it==T.begin())ans++;
		else it--,T.erase(it);
		T.insert(A[i]);
	}
	cout<<ans;
	return 0;
}

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

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

  ll N; cin >> N;
  ll M = 1e7 + 5;
  vector<ll> f(M, 1);
  for (ll i = 2; i < M; i++) {
    for (ll j = 1; j < N; j++) {
      if (i * j > M) break;
      f[i * j]++;
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ans += (i * f[i]);
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int solve(int a, int b, int k) {
  for (int i = 100; i > 0; --i) {
    if (a % i == 0 && b % i == 0) {
      --k;
      if (k == 0) {
        return i;
      }
    }
  }
  return 2;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int a, b, k;
  std::cin >> a >> b >> k;
  std::cout << solve(a, b, k) << std::endl;
  return 0;
}


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

const string Chord[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};

bool solve(int k, int p, const vector<string>& T, const vector<string>& S)
{
  if (k == 0) {
    if (p == -1)
      return true;
    return false;
  }

  bool ret = false;
  // k+1
  if (S[p] == T[k])
    ret |= solve(max(0, k-1), p-1, T, S);

  // k+2
  if (k-2 >= 0) {
    for (int i = 0; i < 12; ++i) {
      if (Chord[i] == T[k]) {
        if (Chord[(i+1)%12] == S[p])
          ret |= solve(max(0, k-2), p-1, T, S);
        break;
      }
    }
  }

  // k-1
  if (k+1 < (int)T.size()-1) {
    for (int i = 0; i < 12; ++i) {
      if (Chord[i] == T[k]) {
        if (Chord[(12+i-1)%12] == S[p])
          ret |= solve(k+1, p-1, T, S);
        break;
      }
    }
  }

  return ret;
}

int main()
{
  int T;
  cin >> T;
  while  (T--) {
    int n, m;
    cin >> n >> m;
    vector<string> t(n+2), s(m);
    for (int i = 0; i < n; ++i)
      cin >> t[i+1];
    for (int i = 0; i < m; ++i)
      cin >> s[i];

    if (solve(n-1, m-1, t, s) || solve(n, m-1, t, s))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

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

const ll INF = (ll)1e18;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  ll ans = 1;
  rep(i, n) {
    if (ans*a[i] > INF || (ans && (INF+1)/ans < a[i])) {
      ans = -1;
      break;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}


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

int main(){
  int r,g,b;
  cin>>r>>g>>b;
  int k;
  cin>>k;
  int cnt=0;
  while(r>=g){
    g*=2;
    cnt+=1;
  }
  while(g>=b){
    b*=2;
    cnt+=1;
  }
  if(cnt<=k){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    long double s=1,sum=0;
    cin>>n;
    long double a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
        s*=a[i];
    }
    for(long long i=0;i<n;i++){
        sum+=s/a[i];
    }
    printf("%0.8llf",s/sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int ma=3005;
ll dp[ma][ma];
ll s[ma][ma];
const int MOD = (1e9 + 7);
int add(int a, int b)
{
    a+=b;
    while(a>=MOD) a-=MOD;
    return a;
}
int sum(int i, int l, int r)
{
    l=max(l,0);
    if(l>r) return 0;
    if(l==0) return s[i][r];
    else return add(s[i][r],MOD-s[i][l-1]);
}
void solve(){
    int n;
    string st;
    cin>>n>>st;
    dp[0][0]=1;
    s[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<=i;j++){
            if(st[i-1]=='<'){
                dp[i][j]=sum(i-1,0,j-1);
            }
            else{
                dp[i][j]=sum(i-1,j,i-1);
            }
        }
        for(int j=0;j<=i;j++){
            s[i][j]=dp[i][j];
            if(j>0)
                s[i][j]=add(s[i][j],s[i][j-1]);
        }
    }
    int ans=0;
    for(int i=0;i<n;i++) ans=add(ans,dp[n-1][i]);
    cout<<ans<<endl;

}
int main(){
    int t=1;

    while(t--)solve();

}


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

int r, g, b, n, ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> r >> g >> b >> n;
	for(int i=0; i<=n/r; ++i)
		for(int j=0; j<=n/g; ++j){
			int t = n - i*r - j*g;
			if(t >= 0 && t % b == 0) ++ans;
		}
	cout << ans << "\n";
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        h: usize,
    }
    println!("{}", solve(h));
}

fn solve(h: usize) -> usize {
    if h == 1 {
        1
    } else {
        solve(h / 2) * 2 + 1
    }
}


Measured memory_bytes: 4352
//csjosh

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp> //required
// using namespace __gnu_pbds; //required 
using namespace std;

#define ll long long 
#define loop(x) for(int i=0;i<x;i++)

#define llu unsigned long long 
#define pb push_back
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
// ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }

// typedef tree<
// pair<int, int>,
// null_type,
// less<pair<int, int>>,
// rb_tree_tag,
// tree_order_statistics_node_update> ordered_set;
 
int n;
ll a[400006];
ll h[400006];
ll tree[4*1000005];
ll update(int root,int x,int start,int end,ll val){
  if((x<start)||(x>end))
    return 0;
  if(start==end)
  {
    tree[root]=max(tree[root],val);
    return tree[root];
  }
  ll p1=0,p2=0;
     int mid=(start+end)/2;
  p1=update(2*root,x,start,mid,val);
     
  p2=update(2*root+1,x,mid+1,end,val);
  return tree[root]=max(tree[root],max(p1,p2));
   
}
ll query(int root,int l,int r,int start,int end){
    if(start>end)
    return 0;
  if(r<start||l>end)
    return 0;
  if(l<=start&&r>=end)
    return tree[root];


  int mid=(start+end)/2;
  ll p1=query(2*root,l,r,start,mid);
  ll p2=query(2*root+1,l,r,mid+1,end);
  return max(p1,p2);
}
int main(){
    IOS;  
   
   cin>>n;
  //memset(bit,0,sizeof bit);
   loop(n)cin>>h[i+1];
   loop(n)cin>>a[i+1];
   //first use of segment trees
   ll maxsum=0;
    for(int i=1;i<=n;i++){
      maxsum=query(1,1,h[i],1,n)+a[i];
      update(1,h[i],1,n,maxsum);
    }
    cout<<query(1,1,n,1,n)<<endl;
   
 }



Measured memory_bytes: 12544
class Solution:
    def solve(self, n: int) -> str:

        prods = set()

        for i in range(1, 10):
            for j in range(i, 10):
                prods.add(i*j)

        if n in prods:
            return 'Yes'
        else:
            return 'No'


if __name__ == '__main__':

    # standard input
    n = int(input())

    # solve
    solution = Solution()
    print(solution.solve(n))


Measured memory_bytes: 2940