akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

#pragma warning(disable : 4996)

#define INF 1000000000

using namespace std;

const vector<int> dx = { 0, 1, 1, 1, 0, -1, -1, -1 };
const vector<int> dy = { -1, -1, 0, 1, 1, 1, 0, -1 };

int H, W; vector<string> M;

vector<vector<int> > state;

int check(int x, int y, int s)
{
	int ret = 0;

	for (int dir = 0; dir < 8; dir++)
	{
		if (state[y + dy[dir]][x + dx[dir]] < s || M[y + dy[dir]][x + dx[dir]] == '.')
		{
			ret++;
		}
	}

	return ret;
}

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	M = vector<string>(H);

	for (int i = 0; i < H; i++) cin >> M[i];

	state = vector<vector<int> >(H, vector<int>(W, INF));

	queue<pair<int, int> > que;

	for (int i = 1; i < H - 1; i++)
	{
		for (int j = 1; j < W - 1; j++)
		{
			if (check(j, i, 1) >= M[i][j] - 48 && M[i][j] != '.')
			{
				que.push(make_pair(j, i)); state[i][j] = 1;
			}
		}
	}

	while (!que.empty())
	{
		int x = que.front().first;
		int y = que.front().second; que.pop();

		for (int dir = 0; dir < 8; dir++)
		{
			int x2 = x + dx[dir];
			int y2 = y + dy[dir];

			if (state[y2][x2] == INF && M[y2][x2] != '.' && check(x2, y2, state[y][x] + 1) >= M[y2][x2] - 48)
			{
				state[y2][x2] = state[y][x] + 1;

				que.push(make_pair(x2, y2));
			}
		}
	}

	int ret = 0;

	for (int i = 1; i < H - 1; i++)
	{
		for (int j = 1; j < W - 1; j++)
		{
			if (state[i][j] != INF)
			{
				ret = max(ret, state[i][j]);
			}
		}
	}

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

	return 0;
}

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

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

    int S_size = S.size();
    int T_size = T.size();
    int min, count;

    min = 1000;
    for(int i = 0; i < S_size - T_size + 1; i++){
        count = T_size;
        for(int n = 0; n < T_size; n++){
            if(S[i + n] == T[n]){
                count--;
            }
        }
        if(min > count){
            min = count;
        }
    }

    cout << min << endl;
}

Measured memory_bytes: 3628
import numpy

N, D = (int(x) for x in input().split())
points = []
points.extend(list(int(x) for x in input().split()) for _ in range(N))

def cal_distance(point1, point2):
    return numpy.linalg.norm(numpy.array(point1) - numpy.array(point2))

if __name__ == "__main__":
    counter = 0
    for i in range(N):
        for j in range(i + 1, N):
            #print(cal_distance(points[i], points[j]))
            if cal_distance(points[i], points[j]).is_integer():
                counter += 1

    print(counter)


Measured memory_bytes: 12432
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int n, m;
    read(n, m);
    print((n == m) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n[100] = {0};
	int s[1000][1000] = {0};
	double a[100] = {0};
	double m[100] = {0};
	int i = 0;
	do{
		cin >> n[i];
		for(int j = 0; j < n[i]; j++){
			cin >> s[i][j];
			m[i] += s[i][j];
		}
		m[i] /= n[i];
		for (int j = 0; j < n[i]; ++j)
		{
			a[i] += pow(s[i][j] - m[i],2.0);
		}
		a[i] = sqrt(a[i]/n[i]);
		i++;
	}while(n[i-1] != 0);
	i = 0;
	do{
		cout << fixed << setprecision(8);
		cout << a[i] << endl;
		i++;
	}while(n[i] != 0);
}

Measured memory_bytes: 5152
package main

import (
	"bufio"
	. "fmt"
	"os"
	"strconv"
)

var (
	inn = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()
	inn.Buffer([]byte{}, 1000000)
	inn.Split(bufio.ScanWords)
	//prep
    n:=rd();
    a:=make([]int64,n)
    for i:=0;i<n;i++{
        a[i]=rdll();
        if(a[i]==0){
            Fprint(out,0);
            return;
        }
    }
    var res int64=1;
    for _,x:=range a{
        if(res!=0&&x>int64(1e18)/res){
            Fprint(out,-1);
            return;
        }
        res*=x;
    }
    Fprint(out,res);
}

//-------------------template------------------
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func maxll(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	x, _ = strconv.Atoi(string(inn.Bytes()))
	return x
}
func rdll() (x int64) {
	inn.Scan()
	x, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)
	return x
}
func rds() string {
	inn.Scan()
	return string(inn.Bytes())
}



Measured memory_bytes: 5844
#include <bits/stdc++.h>
using namespace std;
    
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
#define endl '\n'
#define N 10000002
#define MOD 1000000007

int dp[101][4][4][4];

int f(int n, int a = 3, int b = 3, int c = 3) {
    if(n <= 0)  return 1;
    int ans = 0;
    if(dp[n][a][b][c] != -1)    return dp[n][a][b][c];
    for(int d = 0; d < 4; d++) {
        if(d == 2 && c == 1 && b == 0)  continue;
        if(d == 1 && c == 2 && b == 0)  continue;
        if(d == 2 && c == 0 && b == 1)  continue;
        if(a == 0 && b == 1 && d == 2)  continue;
        if(a == 0 && c == 1 && d == 2)  continue;
        ans += f(n - 1, b, c, d);
        ans %= MOD;
    }
    return dp[n][a][b][c] = ans;
}
    
signed main() {
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    cout << f(n) << endl;        
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
int read()
{
	int s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
}
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
const int maxn=111;
int A[maxn];
int main()
{
	int N=read();
	memset(A,0x3f,sizeof(A));
	for(int i=1;i<N;++i)
	{
		int a=read();
		A[i]=min(A[i],a);
		A[i+1]=min(A[i+1],a);
	}
	int ans=0;
	for(int i=1;i<=N;++i) ans+=A[i];
	write(ans);
	return 0;
}

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

using namespace std;

long long combination2(long long n)
{
	return n * (n - 1) / 2;
}


int main()
{
	int N;
	cin >> N;
	vector<int> balls(N+1);
	vector<int> count(N+1);
	//unordered_multiset<int> ballscount;



	long long ans = 0;
	long long tot = 0;

	for (int i = 1; i <= N; i++)
	{
		int a;
		cin >> a;
		balls[i] = a;
	}

	for (int i = 0; i <= N; i++)
	{
		count[balls[i]]++;
	}

	for (int i = 0; i <= N; i++)
	{
		tot += combination2(count[i]);
	}



	for (int i = 1; i <= N; i++)
	{
		ans = tot;
		ans -= combination2(count[balls[i]]);
		ans += combination2(count[balls[i]] - 1);
		cout << ans << endl;
	}



	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;



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

    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        A[i] = tmp - 1;
    }

    vector<ll> seen(N, -1);
    vector<ll> B;
    ll idx = 0;
    ll count = 0;
    while(seen[idx] == -1) {
        //cout << idx << endl;
        B.push_back(idx);
        seen[idx] = count++;
        idx = A[idx];
    }

    if (K <= seen[idx]) cout << B[K] + 1 << endl;
    else {
        K -= seen[idx];
        cout << B[seen[idx] + (K % (count-seen[idx]))] + 1<< endl;
    }

    return 0;
}

Measured memory_bytes: 8480
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    string S;
    in(S);
    if (S == "ABC") out("ARC");
    else out("ABC");

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_C(){
    int h, w, k;
    cin >> h >> w >> k;
    char c[h][w];
    REP(i,h) REP(j,w) cin >> c[i][j];

    int ans = 0;
    for(int bith = 0; bith < (1 << h); bith++){
        for(int bitw = 0; bitw < (1 << w); bitw++){
            int black = 0;
            for(int i = 0; i < h; i++){
                if(bith & (1 << i)) continue;
                for(int j = 0; j < w; j++){
                    if(bitw & (1 << j)) continue;
                    if(c[i][j] == '#') black++;
                }
            }
            if(black == k) ans++;
        }
    }

    cout << ans << endl;
}

void solve_D(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    sort(a.rbegin(), a.rend());

    int t = n-2;
    ll ans = a[0];
    for(int i = 1; i < n; i++){
        REP(j,2){
            if(t > 0){
                ans += a[i];
                t--;
            }
        }
    }

    cout << ans << endl;
}

int main(void){
    solve_D();
    
    return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, w;
    cin >> n >> w;
    vector<pair<int, long long>> sack(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> sack[i].first >> sack[i].second;
    }
    sort(sack.begin(), sack.end());
    vector<long long> dp(w + 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = w; j >= sack[i].first; j--)
        {
            dp[j] = max(dp[j], dp[j - sack[i].first] + sack[i].second);
        }
    }
    cout << dp[w];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

ll gcd(ll a,ll b){
    if(a == 0 && b == 0) return 0;
    else if(a == 0|| b == 0) return 1;
    else{
        if(a < 0) a = -a;
        if(b < 0) b = -b;
        if(a < b) swap(a,b);
        while(true){
            ll p = a % b;
            a = b;
            b = p;
            if(p == 0)break;
        }
        return a;
    }
}

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

int count2(ll a){
    int count = 0;
    while(a % 2 == 0){
        count++;
        a /= 2;
    }
    return count;
}
/*ll gcd(ll a, ll b){
    if(a < b)swap(a,b);
    while(a)
}*/

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N; ll M; cin >> N >>M;
    vector<ll> A(N);
    ll nowlcm = 1;
    int count;
    bool flag = false;
    REP(i,N){
        ll a; cin >> a;
        a /= 2;
        if(i == 0){
            count = count2(a);
        }
        else{
            int now = count2(a);
            if(count != now){
                flag = true;
                break;
            }
        }
        A[i] = a;
        //ll g = gcd(a,nowlcm);
        nowlcm = lcm(a,nowlcm);
        if(nowlcm > M){
            flag = true;
            break;
        }

    }
    if(flag){
        cout << 0 << endl;
        return 0;
    }

    //cout << nowlcm << endl;
    ll ans = ((M / nowlcm) + 1) / 2;
    cout << ans << endl;


}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

class RMQ{
public:
  int n;
  P dat[3555555];
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    rep(i,2*n) dat[i]=P(-MAX,-1);
  }
  void update(int k,P a){
    k+=n-1;dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }
  P query(int a,int b){return query(a,b,0,0,n);}
  P query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return P(-MAX,-1);
    if(a<=l&&r<=b) return dat[k];
    P vl=query(a,b,k*2+1,l,(l+r)/2);
    P vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr);
  }
};

RMQ t;
priority_queue<ll> que[1000001];

void Main() {
  ll n;
  R n;
  string s[n];
  rep(i,n) R s[i];
  rep(i,n) {
    string t="";
    ll x=0;
    rep(j,s[i].size()) {
      if(s[i][j]=='(') x++;
      else if(x) x--;
      else t+=')';
    }
    rep(j,x) t+='(';
    s[i]=t;
  }
  ll c[2];
  mem(c);
  rep(i,n) {
    rep(j,s[i].size()) {
      if(s[i][j]=='(') c[0]++;
      else c[1]++;
    }
  }
  if(c[0]!=c[1]) {
    pr("No");
    return;
  }
  t.init(1000001);
  rep(i,n) {
    ll M=0,x=0;
    rep(j,s[i].size()) {
      if(s[i][j]=='(') x++;
      else x--;
      M=min(M,x);
    }
    que[-M].push(x);
  }
  rep(i,1000001) {
    if(que[i].size()) t.update(i,P(que[i].top(),i));
  }
  ll x=0;
  rep(i,n) {
    P p=t.query(0,x+1);
    if(p.S==-1) {
      pr("No");
      return;
    }
    if(p.F<0) break;
    x+=p.F;
    if(x<0) {
      pr("No");
      return;
    } 
    que[p.S].pop();
    if(que[p.S].size()) t.update(p.S,P(que[p.S].top(),p.S));
    else t.update(p.S,P(-MAX,-1));
  }
  vector<P> v;
  rrep(i,1000001) {
    while(que[i].size()) {
      v.pb(P(i+que[i].top(),que[i].top()));
      que[i].pop();
    }
  }
  sort(all(v));
  rrep(i,v.size()) {
    ll y=v[i].F-v[i].S;
    if(x-y<0) {
      pr("No");
      return;
    }
    x+=v[i].S;
  }
  if(!x) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 137332
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
	int i,j;
	char str[85],str1[85],buf;
	while(gets(str) != NULL){
		for(i = 0;i < 26;i++){
			for(j = 0;j < strlen(str);j++){
				if(islower(str[j])) str[j] = (str[j] - 96) % 26 + 97;
			}
			strcpy(str1,str);
			if(strstr(str1,"this") || strstr(str1,"the") || strstr(str1,"that")){
				 printf("%s\n",str);
				 break;
			}
		}
	}
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
ll A[MAX_N];
ll F[MAX_N];

ll need(int N, ll score) {
  ll res = 0;
  REP(i, N) {
    res += max(0LL, A[i] - score / F[i]);
  }
  return res;
}

int main2() {
  int N = nextInt();
  ll K = nextLong();
  REP(i, N) A[i] = nextLong();
  REP(i, N) F[i] = nextLong();
  sort(A, A+N);
  sort(F, F+N); reverse(F, F+N);

  ll hi = 1LL << 61;
  ll lo = -1;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (need(N, mid) <= K) hi = mid; else lo = mid;
  }
  ll ans = hi;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

S = input().strip()

def rec(S):
    N = len(S)
    for i in range(N//2):
        if S[i] != S[N-i-1]:
            return False
    return True

if rec(S) and rec(S[:(len(S)-1)//2]) and rec(S[(len(S)+3)//2-1:]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  char c; cin >> c;
  if (c>='A' && c<='Z') cout << 'A' << endl;
  else cout << 'a' << endl;

  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3588
using System;

using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
 {
        static void Main(string[] args)
        {
          int cnt = 0;// true
          
          int n = int.Parse(Console.ReadLine());
          
          string[] str = Console.ReadLine().Split(' ');
          
          int[] a = new int[n];
          int a_len = a.Length;
          for(int i = 0 ; i < n ; i++){
            a[i] = int.Parse(str[i]);
          }
          
          int[] a_D = a.Distinct().ToArray();
          
          //Console.WriteLine(string.Join(" ", a_D));
          if(a_len == a_D.Length){
            Console.WriteLine("YES");
          }
          else{
            Console.WriteLine("NO");
          }
        }
 }

Measured memory_bytes: 40220
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n), b(n);
    rep(i,n) cin>>a[i]>>b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if (n%2) {
        ll mini = a[n/2];
        ll maxi = b[n/2];
        cout << maxi-mini+1 << '\n';
    }
    else {
        ll mini = a[n/2]+a[n/2-1];
        ll maxi = b[n/2]+b[n/2-1];
        cout << maxi-mini+1 << '\n';
    }
    return 0;
}

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


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

	int n, ans = 0, x = 0;
	string s;

	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
		}
		else {
			x--;
		}

		ans = max(ans, x);
	}
	cout << ans << '\n';
	
	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 REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

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

    string f,l;
    f = s.substr(0,2);
    l = s.substr(2,2);
    int fi =stoi(f);
    int li = stoi(l);

    bool a=true;
    bool b=true;
    if(li<=12&&li>0){
        a=true;
    }else{
        a=false;
    }
    if(fi<=12&&fi>0){
        b=true;
    }else{
        b=false;
    }

    if(a&b){
        cout<<"AMBIGUOUS"<<endl;
        return 0;
    }
    if(a){
        cout<<"YYMM"<<endl;
        return 0;
    }
    if(b){
        cout<<"MMYY"<<endl;
        return 0;
    }

    if(!(a||b)){
        cout<<"NA"<<endl;
        return 0;
    }




    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
const int MOD = 1e9 + 7;
typedef long long ll;

ll n, k, arr[MAXN], ans, flg;

inline ll fabs(const ll &x){return x < 0 ? -x : x;}
bool cmp(const ll &x, const ll &y){return fabs(x) > fabs(y);}
ll qpow(ll x, ll pwr){
	if(pwr == 0) return 1;
	ll tmps = qpow(x, pwr >> 1);
	if(pwr & 1) return (tmps * tmps % MOD) * x % MOD;
	else return tmps * tmps % MOD;
}

int main(){
	scanf("%lld %lld", &n, &k);
	bool flag = false;
	for(ll i = 1; i <= n; i++){
		scanf("%lld", &arr[i]);
		if(arr[i] > 0) flag = true;
	}
	sort(arr + 1, arr + n + 1, cmp);
	if(!flag && k % 2 == 1){
		ans = 1;
		for(ll i = n; i >= n - k + 1; i--)
			ans = ans * arr[i] % MOD;
		ans = (ans + MOD) % MOD;
		printf("%lld\n", ans);
		return 0;
	}
	if(n == k){
		ans = 1;
		for(ll i = 1; i <= k; i++) ans = ans * arr[i] % MOD;
		printf("%lld\n", (ans + MOD) % MOD);
		return 0;
	}
	ans = 1; flg = 1;
	for(ll i = 1; i <= k; i++){
		if(arr[i] < 0) flg = flg ^ 1;
		ans = ans * fabs(arr[i]) % MOD;
	}
	if(flg) printf("%lld\n", ans);
	else{
		if(ans == 0){
			printf("%lld\n", 0);
			return 0;
		}
		ll next_pos = -1, next_neg = -1;
		for(ll i = k + 1; i <= n; i++){
			if(arr[i] > 0 && next_pos == -1) next_pos = arr[i];
			else if(arr[i] <= 0 && next_neg == -1) next_neg = -arr[i];
		}
		ll last_pos = -1, last_neg = -1;
		for(ll i = k; i >= 1; i--){
			if(arr[i] > 0 && last_pos == -1) last_pos = arr[i];
			else if(arr[i] < 0 && last_neg == -1) last_neg = -arr[i];
		}
//		printf(":%lld %lld %lld %lld %lld\n", ans, last_pos, last_neg, next_pos, next_neg);
		if((last_pos == -1 || next_neg == -1) && (next_pos == -1 || last_neg == -1)) ans = (-ans + MOD) % MOD;
		else if(last_neg == -1 || next_pos == -1) ans = (ans * qpow(last_pos, MOD - 2) % MOD) * next_neg % MOD;
		else if(last_pos == -1 || next_neg == -1) ans = (ans * qpow(last_neg, MOD - 2) % MOD) * next_pos % MOD;
		else if(last_pos * next_pos > last_neg * next_neg) ans = (ans * qpow(last_neg, MOD - 2) % MOD) * next_pos % MOD;
		else ans = (ans * qpow(last_pos, MOD - 2) % MOD) * next_neg % MOD;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 5340
#include <iostream>
#include <algorithm>

using namespace std;

int n, ans;
int L[205];

int main()
{
    cin >> n;
    for(int i = 0; i < 2 * n; i++) cin >> L[i];
    sort(L,L+2*n);
    for(int i = 0; i < n; i++) ans += L[2*i];
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

int H, W;
vector<string> s;

vector<vector<int>> dp;

// // 今座標(h, w)にいて、それまでにnum回操作した。一回前に操作したかどうかがprev。
// void dfs(int h, int w, int num, bool prev)
// {
//   if (h == H - 1 && w == W - 1)
//   {
//     if (s[h][w] == '#' && !prev)
//       num++;
//     ans = min(ans, num);
//     return;
//   }

//   if (h == H - 1)
//   {
//     if (s[h][w] == '#')
//     {
//     }
//   }
// }

int main()
{
  cin >> H >> W;
  s.resize(H);
  for (int i = 0; i < H; i++)
  {
    cin >> s[i];
  }
  dp.assign(H, vector<int>(W));

  if (s[0][0] == '#')
  {
    dp[0][0] = 1;
  }
  else
  {
    dp[0][0] = 0;
  }

  int up, left;

  for (int i = 1; i <= H + W - 2; i++)
  {
    for (int h = max(0, i - W + 1); h <= min(i, H - 1); h++)
    {
      int w = i - h;
      if (s[h][w] == '#')
      {
        if (h == 0)
        {
          if (s[h][w - 1] == '#')
          {
            dp[h][w] = dp[h][w - 1];
          }
          else
          {
            dp[h][w] = dp[h][w - 1] + 1;
          }
          continue;
        }
        if (w == 0)
        {
          if (s[h - 1][w] == '#')
          {
            dp[h][w] = dp[h - 1][w];
          }
          else
          {
            dp[h][w] = dp[h - 1][w] + 1;
          }
          continue;
        }

        if (s[h - 1][w] == '#')
        {
          up = dp[h - 1][w];
        }
        else
        {
          up = dp[h - 1][w] + 1;
        }

        if (s[h][w - 1] == '#')
        {
          left = dp[h][w - 1];
        }
        else
        {
          left = dp[h][w - 1] + 1;
        }

        dp[h][w] = min(up, left);
      }
      else
      {
        if (h == 0)
        {
          dp[h][w] = dp[h][w - 1];
          continue;
        }
        if (w == 0)
        {
          dp[h][w] = dp[h - 1][w];
          continue;
        }

        up = dp[h - 1][w];
        left = dp[h][w - 1];

        dp[h][w] = min(up, left);
      }
    }
  }

  cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef vector<int> vi;
typedef long long LL;
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	bool f = false;
	while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
	if(ch == '-'){f = true; ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
	if(f) x = -x;	
}
int n, k;
vi a[6], A;
inline vi inv(const vi &p){
	vi q(n);
	for(Rint i = 0;i < n;++ i) q[p[i]] = i;
	return q;
}
inline vi mul(const vi &p, const vi &q){
	vi r(n);
	for(Rint i = 0;i < n;++ i) r[i] = p[q[i]];
	return r;
}
inline vi ksm(vi a, int b){
	vi res(n);
	for(Rint i = 0;i < n;++ i) res[i] = i;
	while(b){
		if(b & 1) res = mul(res, a);
		a = mul(a, a); b >>= 1;
	}
	return res;
}
int main(){
	read(n); read(k); -- k;
	a[0].resize(n); for(Rint i = 0;i < n;++ i) read(a[0][i]), -- a[0][i];
	a[1].resize(n); for(Rint i = 0;i < n;++ i) read(a[1][i]), -- a[1][i];
	for(Rint i = 2;i < 6;++ i) a[i] = mul(a[i - 1], inv(a[i - 2]));
	if(k < 6){for(Rint i = 0;i < n;++ i) printf("%d ", a[k][i] + 1); return 0;}
	A = ksm(mul(mul(a[1], inv(a[0])), mul(inv(a[1]), a[0])), k / 6);
	A = mul(mul(A, a[k % 6]), inv(A));
	for(Rint i = 0;i < n;++ i) printf("%d ", A[i] + 1); 
}

Measured memory_bytes: 5368
#!/usr/bin/env python3
import sys


def solve_iter(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    f = [[0] * N for _ in range(N)]
    for l, r in zip(L, R):
        f[l-1][r-1] += 1
    dp = [[0] * (N + 1) for _ in range(N+1)]
    for h in range(N):
        for w in range(N):
            dp[h+1][w+1] = dp[h+1][w] + dp[h][w+1] - dp[h][w] + f[h][w]

    #print(*f, sep='\n')
    #print(*dp, sep='\n')
    for pp, qq in zip(p, q):
        #yield pp, qq, dp[qq][qq] - dp[qq][pp-1] - dp[pp-1][qq] + dp[pp-1][pp-1]
        yield dp[qq][qq] - dp[qq][pp-1] - dp[pp-1][qq] + dp[pp-1][pp-1]

def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    return list(solve_iter(N, M, Q, L, R, p, q))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    print(*solve(N, M, Q, L, R, p, q), sep='\n')

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 32828
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
const int N = 1e5 + 10;
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;
ll num[100];
int main()
{

    string a, b, c;
    while (cin >> a >> b >>c)
    {

        if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 55;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int dp[N][N][64];
int a[N][N], pre[N], cur[N];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, mask; cin>>n>>mask;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            cin>>a[i][j];
            if(a[i][j]){
                dp[i][j][0]=1;
            }
        }
    }
    for(int p=1; p<64; p++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                for(int k=1; k<=n; k++){
                    dp[i][j][p]+=((dp[i][k][p-1]*dp[k][j][p-1])%MOD);
                    dp[i][j][p]%=MOD;
                }
            }
        }
    }
    int p=0;
    For(i, 1, n+1){
        pre[i]=1;
    }
    while(mask){
        if(mask%2==0){
            p++;
            mask/=2;
            continue;
        }
        memset(cur, 0, sizeof(cur));
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                cur[j]+=((pre[i]*dp[i][j][p]))%MOD;
                cur[j]%=MOD;
            }
        }
        for(int i=1; i<=n; i++){
            pre[i]=cur[i];
        }
        p++;
        mask/=2;
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        ans+=pre[i];
        ans%=MOD;
    }
    cout<<ans;
    return 0;
}




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

int main()
{
   ll N;
   cin >> N;
   vector<ll>A(N),B(N),C(N);
   for(int i = 0; i < N;i++) cin >> A[i];
   for(int i = 0; i < N;i++) cin >> B[i];
   for(int i = 0; i < N;i++) cin >> C[i];
   sort(A.begin(),A.end()),sort(B.begin(),B.end()),sort(C.begin(),C.end());
   ll ans = 0;
   for(auto x:B)
   {
       vector<ll>::iterator itr1 = lower_bound(A.begin(),A.end(),x);
       itr1--;
       if(*itr1 == 0) continue;
       vector<ll>::iterator itr2 = upper_bound(C.begin(),C.end(),x);
       if(itr2 == C.end()) continue;
       ans += (distance(A.begin(),itr1) + 1)*(N - distance(C.begin(),itr2));
   }
   cout << ans << endl;
}

Measured memory_bytes: 5568
while True:
    n = int(input())
    if n == 0:
        break
    result = {}
    order = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if e in result:
            result[e] += p*q
        else:
            result[e] = p*q
            order.append(e)
    flag = True
    for e_i in order:
        if result[e_i] >= 1000000:
            print(e_i)
            flag = False
    if flag:
        print("NA")



Measured memory_bytes: 5824
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int ga,sa,ba,gb,sb,bb;
    cin>>ga>>sa>>ba>>gb>>sb>>bb;
    vector<ll> dp(n+1,0);
    for(int i=0;i<=n;i++){
        dp.at(i)=i;
        if(i>=ga)dp.at(i)=max(dp.at(i),dp.at(i-ga)+gb);
        if(i>=sa)dp.at(i)=max(dp.at(i),dp.at(i-sa)+sb);
        if(i>=ba)dp.at(i)=max(dp.at(i),dp.at(i-ba)+bb);
    }
    int ma=dp.at(n);
        vector<ll> dp2(ma+1,0);
         for(int i=0;i<=ma;i++){
        dp2.at(i)=i;
        if(i>=gb)dp2.at(i)=max(dp2.at(i),dp2.at(i-gb)+ga);
        if(i>=sb)dp2.at(i)=max(dp2.at(i),dp2.at(i-sb)+sa);
        if(i>=bb)dp2.at(i)=max(dp2.at(i),dp2.at(i-bb)+ba);
    }
    cout<<dp2.at(ma)<<endl;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll X;
  cin  >>X;
  rep(i,360){
    if(((i+1)*360)%X==0){
      cout << ((i+1)*360)/X << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3628
n = int(input())

i = 1
s = ""
count = 0
while count != n:
    if i%2 == 1:
        if (n-count)%(2**i)==0:
            s = "0" + s
        else:
            s = "1" + s
            count += 2**(i-1)
    else:
        if (n-count)%(2**i)==0:
            s = "0" + s
        else:
            s = "1" + s
            count -= 2**(i-1)
    i+=1
if n==0:
    s = "0"
print(s)

Measured memory_bytes: 38256
A, B = [int(str) for str in input().split()]

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


print(len(set(prime_factorize(gcd(A, B)))) + 1)

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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

struct io {
    io() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.tie(0);
        cout << fixed << setprecision(20);
    }
} io;

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int N;
vi A;
int ans;
map<int, int> colors;

signed main() {

    in(N);
    A.resize(N);
    in(A);
    colors[A[0]]++;
    REP(i, 1, N) {
        auto iter = colors.lower_bound(A[i]);
        if (iter == colors.begin()) {
            colors[A[i]]++;
        } else {
            iter--;
            iter->second--;
            if (iter->second == 0) {
                colors.erase(iter);
            }
            colors[A[i]]++;
        }

    }
    for (auto e:colors) {
        ans += e.second;
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 7168
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int  n;
  cin >> n;
  vector<bool> pr(n + 1, true);
  REP(i, 2, n + 1) {
    REP(j, 2, n / i + 1) {
      pr[i * j] = false;
    }
  }
  ll sum = 1;
  REP(p, 2, n + 1) {
    if (pr[p]) {
      // count p
      int v = n;
      int cnt = 0;
      while (v > 0) {
	v /= p;
	cnt += v;
      }
      sum *= cnt + 1;
      sum %= mod;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int obs,rd;
  cin >> obs >> rd;
 // vector<long long> hgt(obs);
  map<int,long long> o_h;
  map<int,int> res;
  map<int,bool> mp;
  int a,b;
  
  for(int i = 0; i < obs; i++){
    long long x;
    cin >> x;
  //  hgt[i] = x;
    o_h[i+1] = x;
  }
 // cout << res[1];
  
  for(int i = 0; i < rd; i++){
    cin >> a >> b;
    if(o_h[a] <= o_h[b]){
      res[a] = -1;
    }
    if(o_h[b] <= o_h[a])res[b] = -1;
  //  mp[a] = mp[b] = true;
  }
  int cnt = 0;
  for(int i = 1; i <= obs; i++){
    if(res[i] != -1)cnt++;
  }
  cout << cnt;
  
}

Measured memory_bytes: 14524
S = input()
T = input()

S_list = list(S)
T_list = list(T)

con = 0
for i in range(len(S_list)-len(T_list) + 1):
  count = 0
  for j in range(len(T_list)):
    if S_list[i + j] == T_list[j]:
      count +=1
  if count > con:
    con = count

ans = len(T_list) - con
print(ans)

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

constexpr int mod = 1e9 + 7;
int64_t dp[220][220];
int main() {
  int n;
  cin >> n;

  vector<bool> ud;
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    if (c == '-') continue;
    ud.push_back(c == 'U');
  }

  dp[0][0] = 1;
  n = ud.size();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (ud[i]) {
        (dp[i + 1][j + 1] += dp[i][j]) %= mod;
        (dp[i + 1][j] += j * dp[i][j]) %= mod;
      } else {
        if (j) (dp[i + 1][j - 1] += j * j * dp[i][j]) %= mod;
        (dp[i + 1][j] += j * dp[i][j]) %= mod;
      }
    }
  }

  cout << dp[n][0] << endl;
}



Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl

#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

const ll N=1000005;


    const ll MOD=1000000007;
    ll fact[N], invfact[N];

    ll pow(ll a, ll b)
    {
        ll ans=1;
        while(b)
        {
            if(b&1)
                ans=(ans*a)%MOD;
            b/=2;
            a=(a*a)%MOD;
        }
        return ans;
    }

    ll modinv(ll k)
    {
        return pow(k,MOD-2);
    }

    void precompute()
    {
        fact[0]=fact[1]=1;
        for(ll i=2;i<N;i++)
        {
            fact[i]=fact[i-1]*i;
            fact[i]%=MOD;
        }
        invfact[N-1]=modinv(fact[N-1]);
        for(ll i=N-2;i>=0;i--)
        {
            invfact[i]=invfact[i+1]*(i+1);
            invfact[i]%=MOD;
        }
    }

    ll nCr(ll x, ll y)
    {
        if(y>x)
            return 0;
        ll num=fact[x];
        num*=invfact[y];
        num%=MOD;
        num*=invfact[x-y];
        num%=MOD;
        return num;
    }

int main(){
	ll n,k;
	precompute();
	cin>>n>>k;
	ll m;
	if(k>n) m=n-1;
	else m=k;
	//dbg2(n,m);
    ll ans=0;
	FOR(i,0,m){
		ans=ans+(nCr(n,i)%MOD*nCr(n-1,i)%MOD)%MOD;
        ans=(ans)%MOD;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 15872
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b):
    if 8>=a and 8>=b:     
        return'Yay!'
    else:
        return':('


# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys, math,os
from io import BytesIO, IOBase
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(Decimal, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7
from decimal import Decimal


def main():

    n=int(data())
    l=[]
    l1=[]
    for i in range(n):
        a,b=mdata()
        l.append(a)
        l1.append(b)
    l.sort()
    l1.sort()
    if n%2!=0:
        a=l[n//2]
        b=l1[n//2]
        cnt=b-a+1
        out(cnt)
    else:
        a1=l[n//2-1]
        b1 = l1[n // 2-1]
        a2=l[n//2]
        b2 = l1[n // 2]
        out(int(((b1+b2)/2-(a1+a2)/2)*2+1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 58064
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    String S[] = new String[N];
    Integer march[] = new Integer[5];
    Arrays.fill(march, 0);
    for(int i=0; i<N; i++){
      S[i] = sc.next();
      if(S[i].charAt(0) == 'M') march[0]++;
      if(S[i].charAt(0) == 'A') march[1]++;
      if(S[i].charAt(0) == 'R') march[2]++;
      if(S[i].charAt(0) == 'C') march[3]++;
      if(S[i].charAt(0) == 'H') march[4]++;
    }
    long ans = 0;
    for(int i=0; i<5; i++){
      for(int j=i+1; j<5; j++){
        for(int k=j+1; k<5; k++){
          ans += (long)march[i] * march[j] * march[k];
        }
      }
    }
    out.println(ans);
    
  }

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

Measured memory_bytes: 51728
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3092