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

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

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

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

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


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

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

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i < 1000; i++) {
        for (int j = 0; j < 1000; j++) {
            if (i * 4 + j * 2 == y && i + j == x) {
                cout << "Yes\n";
                rr;
            }
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

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

    double s = 0.5*(a*b*sin(PI*c/180));

    printf("%.8lf\n",s);

    double cc = sqrt(a*a+b*b-2*a*b*cos(PI*c/180));

    printf("%.8lf\n",a+b+cc);

    double h = 2.0*s/a;

    printf("%.8lf",h);


}


Measured memory_bytes: 3588
S = input()
llist = [0 for i in range(10)]

for i in range(len(S)):
    for j in range(len(S)-i):
        if S[i+j] == "A" or S[i+j] == "T" or S[i+j] == "G" or S[i+j] == "C":
            llist[i] += 1
        else:
            break

print(max(llist))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
using namespace std;
inline int read()
{
    int x = 0,f = 1;char ch = getchar();
    for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
    for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
    return x * f;
}
const int maxn = 1e5 + 10;
int n;int a[maxn];
int main()
{
    n = read();
    for(int i=1;i<=n;i++)a[i] = read();
    sort(a + 1,a + n + 1);reverse(a + 1,a + n + 1);
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(i + 1 > a[i + 1])
		{
			for(int j=i+1;a[j] == i;j++) ans ^= 1;
        	ans |= (a[i] - i) & 1;
        	if(ans)puts("First");
       		else puts("Second");
        	return 0;
		}
	}
}

Measured memory_bytes: 768
program rot_b
    implicit none
    integer(4):: n, i, j
    character(10000):: s, ns
    character(52), parameter:: alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
    read*, n
    read*, s
    do i=1,len_trim(s)
        do j=1, 26
            if (alphabet(j:j) == s(i:i))then
                ns(i:i) = alphabet(j+n:j+n)
            end if
        end do
    end do
    print"(a)", trim(ns(1:len_trim(s)))
end program rot_b

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

vector<int> G;

int main() {
    int N, mod=1000000007;
    string s1, s2;
    cin >> N >> s1 >> s2;
    
    rep(i,N){
        if(s1[i]==s2[i]){
            G.push_back(1);
        }else{
            G.push_back(2);
            i++;
        }
    }
    
    ll ans=3*G[0];
    rep(i,G.size()-1){
        if(G[i]==1){
            ans = ans*2%mod;
        }else if(G[i]==2 && G[i+1]==2){
            ans = ans*3%mod;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
points =[list(map(int, input().split())) for _ in range(N)]

dp = [ [0 , 0 , 0] for _ in range(N + 1)]

for step in range(len(points)):
    # a
    for act in range(3):
        for next_act in range(3):
            if act == next_act:
                continue
            dp[step + 1][next_act] = max(points[step][next_act]+dp[step][act], dp[step + 1][next_act])


print(max(dp[N]))



Measured memory_bytes: 47344
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl v[n],c[n];
    cin(i,v);
    cin(i,c);
    intl a = 0;
    rep(i,n){
        if(v[i] > c[i])a += v[i] - c[i];
    }
    cout << a << endl;
    return 0;
}

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

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] h; readA(n, h);
  int[] a; readA(n, a);

  auto st = new SegmentTree!(long, max)(n+1);
  foreach (i; 0..n)
    st[h[i]] = st[0..h[i]] + a[i];

  writeln(st[0..$]);
}

class SegmentTree(T, alias pred = "a + b")
{
  import core.bitop, std.functional;
  alias predFun = binaryFun!pred;

  const size_t n, an;
  T[] buf;
  T unit;

  this(size_t n, T unit = T.init)
  {
    this.n = n;
    this.unit = unit;
    an = n == 1 ? 1 : (1 << ((n-1).bsr + 1));
    buf = new T[](an*2);
    if (T.init != unit) buf[] = unit;
  }

  this(T[] init, T unit = T.init)
  {
    this(init.length, unit);
    buf[an..an+n][] = init[];
    foreach_reverse (i; 1..an)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  void opIndexAssign(T val, size_t i)
  {
    buf[i += an] = val;
    while (i /= 2)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  pure T opSlice(size_t l, size_t r)
  {
    l += an; r += an;
    T r1 = unit, r2 = unit;
    while (l != r) {
      if (l % 2) r1 = predFun(r1, buf[l++]);
      if (r % 2) r2 = predFun(buf[--r], r2);
      l /= 2; r /= 2;
    }
    return predFun(r1, r2);
  }

  pure T opIndex(size_t i) { return buf[i+an]; }
  pure size_t opDollar() { return n; }
}


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

int main() {
    char s;
    scanf("%c", &s);

    if (s == (char)'S') {
        printf("Cloudy");
        return 0;
    }
    if (s == (char)'C') {
        printf("Rainy");
        return 0;
    }
    printf("Sunny");
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A+B > C+D)
    cout << "Left" << endl;
  else if(A+B == C+D)
    cout << "Balanced" << endl;
  else if(A+B < C+D)
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun 28 20:59:50 JST 2020
 **/

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

Int D;
std::vector<Int> c;
std::vector<std::vector<Int>> s;
constexpr Int K = 26;

Int calc_score(const std::vector<Int>& a) {
    assert(a.size() == D);
    Int ret = 0;
    Int sum = std::accumulate(c.begin(), c.end(), 0LL);
    Int cur_minus = 0;
    std::vector<Int> last(K, -1);
    REP(d, D) {
        cur_minus += sum - c[a[d]] * (d - last[a[d]]);
        ret += s[d][a[d]] - cur_minus;
        last[a[d]] = d;
    }
    return ret;
}

std::chrono::system_clock::time_point start_time;
std::vector<Int> ans(D);
Int best_score;
std::vector<Int> local_search(Int t) {
    std::vector<Int> nxt = ans;
    if (t % 10 == 0) {
        Int idx = rnd() % (D - 1);
        std::swap(nxt[idx], nxt[idx + 1]);
    } else {
        Int idx = rnd() % D;
        nxt[idx] = rnd() % K;
        return nxt;
    }
    return nxt;
}
void hill_climb() {
    std::vector<Int> cnt(2);
    REP(t, 1e9) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        if (std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time).count() > 1900) break;
        // change
        auto nxt = local_search(t);
        Int nxt_score = calc_score(nxt);
        if (nxt_score >= best_score) {
            std::cerr << t << " " << best_score << " " << nxt_score << "\n";
            best_score = nxt_score;
            ans = std::move(nxt);
            cnt[t % 2]++;
        }
    }
    dump(cnt);
}

signed main() {
    start_time = std::chrono::system_clock::now();
    // input
    std::cin >> D;
    c.resize(K);
    s = make_vec<Int>(D, K, 0);
    REP(i, K) std::cin >> c[i];
    REP(i, D) REP(j, K) std::cin >> s[i][j];

    // hoge
    ans.resize(D);
    REP(i, D) ans[i] = i % K;
    best_score = calc_score(ans);
    hill_climb();
    // dump(calc_score(ans));
    // REP(i, D) { ans[i] = std::max_element(s[i].begin(), s[i].end()) - s[i].begin(); }
    // dump(calc_score(ans));

    // output
    for (Int x : ans) std::cout << x + 1 << "\n";
    std::cout << std::endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll X, N;
  cin >> X >> N;
  if (N == 0) {
    cout << X << "\n";
    return 0;
  }
  vector<ll> p(N);
  for (ll i = 0; i < N; ++i) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  ll dif = INF;
  ll ans = -1;
  for (ll i = 0; i <= 101; ++i) {
    ll check = *lower_bound(p.begin(), p.end(), i);
    if (check == i) {
      continue;
    }
    if (abs(X - i) < dif) {
      ans = i;
      dif = abs(X - i);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long n,a,x,y=1,ans;
vector<bool> v[300010];
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a;
		while (a>0){
			v[i].push_back(a%2);
			a/=2;
		}
	}
	for (int i=0;i<n;i++) x=max(x,(long long)v[i].size());
	for (int i=0;i<n;i++) while (v[i].size()<x) v[i].push_back(0);
	for (int i=0;i<x;i++){
		long long num=0,sum=0;
		for (int j=0;j<n;j++)
			if (v[j][i]==0)
				num++;
			else
				sum++;
		num=num*sum%(long long)(1e9+7);
		ans=(ans+num*y)%(long long)(1e9+7);
		y=y*2%(long long)(1e9+7);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 21376
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e5+10;

void io(){
	ios::sync_with_stdio(0);
	cin.tie();
	cout.tie();
}

struct node{
	double x;
	double y;
}p[N];

bool cmp(node a,node b)
{
	return atan2(a.x,a.y)<atan2(b.x,b.y);
} 
int main()
{
	//io();
	int n;cin>>n;
	for(int i=0;i<n;i++)	cin>>p[i].x>>p[i].y;
	sort(p,p+n,cmp);
	double ans=0;
	for(int i=0;i<n;i++){
		double a=0,b=0;
		int now=i;
		do{
			a+=p[now].x;
			b+=p[now].y;
			ans=max(ans,a*a+b*b);
			if(now+1<n)now++;
			else now=0;
		}while(now!=i);
	}
	printf("%.15f\n",sqrt(ans));
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=100353;
int N, M, k;
int arr[MX];
int shift=MX-300;
int st[MX*8];
void up(int L,int R, int p, int i, int j, int val)
{
    if(L > R || L > j || R < i) return ;
    if(L >= i && R <= j)
    {
        st[p]+=val;
        return ;
    }
    int m=(L+R)>>1;
    up(L, m, p<<1, i, j, val);
    up(m+1, R, p<<1|1, i, j, val);
    st[p]=st[p<<1]+st[p<<1|1];
}
int qu(int L, int R, int p, int i, int j)
{
    if(L > R || L > j || R < i) return 0;
    if(L >= i && R <= j) return st[p];
    int m=(L+R)>>1;
    return qu(L, m, p<<1, i, j)+qu(m+1, R, p<<1|1, i, j);
}
ll calc(int x)
{
    memset(st, 0, sizeof st);
    int cur=0;
    ll ret=0;
    for(int i=0;i<N;i++)
    {
        if(arr[i] <= x)
        {
            cur--;
        }
        else
        {
            ++cur;
        }
        if(cur < 0) ++ret;
        ret+=qu(0, shift<<1, 1, cur+1+shift, shift<<1);
        up(0, shift<<1, 1, cur+shift, cur+shift, +1);
    }
    return ret;
}
vector<int> sorted;
bool ch(int mid)
{
    ll all=(ll)(N+1)*N;
    all/=2;
    ll cl=calc(sorted[mid]);
    if(all/2+1 <= cl) return 1;
    return 0;
}
int main()
{
    scanf("%d", &N);

    for(int i=0;i<N;i++)
    {
        scanf("%d", &arr[i]);
        sorted.pb(arr[i]);
    }
    sort(sorted.begin(), sorted.end());
    int lo=0, hi=N-1, R=-1;
    while(lo <= hi)
    {
        int mid=(lo+hi)>>1;
        if(ch(mid))
        {
            hi=mid-1;
            R=mid;
        }
        else lo=mid+1;
    }
    cout<<sorted[R];
    return 0;
}



Measured memory_bytes: 4344
d=1+8*gets.to_i
q=Math.sqrt(d).to_i
if q**2!=d
	puts :No;exit
end
k=(-1+q)/2
puts :Yes,k+1
puts [k,*k.times.map{|i|-~i*(i+2)/2}]*' '
k.times{|i|
	a=[k,i*-~i/2+1]
	i.times{|j|a<<a[-1]+1}
	(i+1...k).each{|j|a<<a[-1]+j}
	puts a*' '
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, m, b[100], a[100][100], c[100] = {};
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++){
    cout << c[i] << endl;
  }
}


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

int main() {
  int N,A;
  cin >> N >> A;
  if (N>=500)
    N = N - N / 500 * 500;
  if (N<=A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

   if( a<b ){
   cout << "a < b";
   } else if( a>b ){
   cout << "a > b";
   }else  {
   cout << "a == b";
   }
   cout << endl;

}


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

bool	check(int dist){
  bool ok=false;
  for(int i=0;i*i<=dist;i++){
    if(i*i==dist)	ok=true;
  }
  return ok;
}

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

Measured memory_bytes: 3588
#pragma GCC optimize (3)
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ff(v,a,b) for(int v=a;v<=b;v++)
#define fr(v,a,b) for(int v=a;v>=b;v--)
#define clr(a,v) memset(a,v,sizeof(a))
#define rep(v,a,b) for(int v=(a);(v)<(b);v++)
#define ll long long
using namespace std;
void rd(int &v) {
	char ch;
	for(ch='*'; ch<'0'||ch>'9'; ch=getchar());
	for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
}
int n,FU[100005],len,a[100005];
int main() {
	cin>>n;
	ff(i,1,n) rd(a[i]);
	len=1;
	FU[1]=a[n];
	fr(i,n-1,1) {
		int k=upper_bound(FU+1,FU+1+len,a[i])-FU;
		if(k>len) FU[++len]=a[i];
		if(FU[k]>a[i]) FU[k]=a[i];
	}
	cout<<len;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main (void){
    long int n, i, dif = -9999999999999, minp = 999999999999;
    
    scanf("%ld", &n);
    
    int r[n];
    
    for(i = 0; i < n; i++){
        scanf("%d", &r[i]);
        if(minp > r[i-1] && i >= 1){ minp = r[i-1]; } 
        
        if(dif < r[i] - minp) dif = r[i] - minp;
        

    }
    
    printf("%ld\n", dif);
    return 0;
    
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int solve(int n,int k,vi a)
{
	sort(all(a));
	int lo=0,hi=n;
	while(lo<hi){
		int mi=(lo+hi)/2;
		vi dp(k); dp[0]=1;
		rep(i,n) if(i!=mi){
			peri(j,a[i],k)
				dp[j]|=dp[j-a[i]];
		}
		if(count(begin(dp)+max(k-a[mi],0),end(dp),1))
			hi=mi;
		else
			lo=mi+1;
	}
	return lo;
}

int main()
{
	for(int n,k;cin>>n>>k&&n|k;){
		vi a(n);
		rep(i,n) cin>>a[i];
		cout<<solve(n,k,a)<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[1] - a[0] == a[2]- a[1]){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

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

const ll INF = 1LL << 60;

/* 0-indexed, [0, n)
 *
 * requirements: let a, b, c in T
 *   op(op(a, b), c) = op(a, op(b, c))
 *   op(a, e) = op(e, a) = e
 */
template<typename T, typename E> class SegmentTree {
public:
  typedef function<T (T, T)> Operator;
  typedef function<T (T, E)> Apply;

  vector<T> data;
  ll n;        // size of elements (2^x alignment)
  T e;         // identity of monoid
  Operator op; // binary operator of monoid
  Apply apply; // apply effect to monoid

  // construct with size of elements
  SegmentTree(ll _n, T e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < _n; n *= 2);
    data.resize(n * 2 - 1, e);
  }

  // construct with initial values
  SegmentTree(const vector<T> &vec, T e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < vec.size(); n *= 2);
    data.resize(n * 2 - 1, e);
    REP(i, 0, vec.size()) data[i + n - 1] = vec[i];
    for(ll i = n - 2; i >= 0; i--) data[i] = op(data[i * 2 + 1], data[i * 2 + 2]);
  }

  // query for [a, b)
  T query(ll a, ll b) { return query(a, b, 0, 0, n); }
  T query(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  // update value at k
  void update(ll k, E x) {
    k += n - 1;
    data[k] = apply(data[k], x);
    while(k > 0) {
      k = (k - 1) / 2;
      data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
};

int main(void) {
  ll N;
  cin >> N;
  vector<ll> H(N), A(N);
  REP(i, 0, N) cin >> H[i];
  REP(i, 0, N) cin >> A[i];

  SegmentTree<ll, ll>::Operator op = [](ll a, ll b) { return max(a, b); };
  SegmentTree<ll, ll>::Apply apply = [](ll a, ll x) { return x; };
  SegmentTree<ll, ll> segtree(N + 1, -INF, op, apply);
  segtree.update(0, 0);

  REP(i, 0, N) {
    segtree.update(H[i], segtree.query(0, H[i]) + A[i]);
  }

  ll ans = -INF;
  REP(i, 0, N + 1) {
    ans = max(ans, segtree.query(i, i + 1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 7424
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <cassert>

using namespace std;

#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {int f[N2], space, MD;};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i = 0; i < N2; ++i){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved(){
  for(int i = 0; i < N2; ++i) if(state.f[i] != i + 1) return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  if(depth + state.MD > limit) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for(int r = 0; r < 4; ++r){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    if(max(prev, r) - min(prev, r) == 2) continue;
    tmp = state;

    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] -1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] -1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if(dfs(depth + 1, r)) { path[depth] = r; return true; }
    state = tmp;
  }

  return false;
}

string iterative_deepening(Puzzle in) {
  in.MD = getAllMD(in);

  for(limit = in.MD; limit <= LIMIT; limit++){
    state = in;
    if(dfs(0, -100)){
      string ans = "";
      for(int i = 0; i < limit; ++i) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main(){
  for(int i = 0; i < N2; ++i)
    for(int j = 0; j < N2; ++j)
      MDT[i][j] = abs(i / N - j / N ) + abs(i % N - j % N);

  Puzzle in;

  for(int i = 0; i < N2; ++i){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 3176
from collections import defaultdict
N = int( input())
ans = 50
X = [ tuple( map( int, input().split())) for _ in range(N)]
X.sort(reverse=True)
for i in range(N-1):
    for j in range(i+1,N):
        if i == j:
            continue
        p = X[i][0] - X[j][0]
        q = X[i][1] - X[j][1]
        d = defaultdict( int)
        now = 0
        for k in range(N):
            if d[X[k]] == 0:
                now += 1
            d[(X[k][0], X[k][1])] = 1
            d[(X[k][0]+p, X[k][1]+q)] = 1
            d[(X[k][0]-p, X[k][1]-q)] = 1
        if now < ans:
            ans = now
if N == 1:
    ans = 1
print(ans)

Measured memory_bytes: 3444
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.util.HashSet;

@SuppressWarnings("unchecked")
public class Main {
    static int f(int s) {
        int cnt = 0;
        HashSet<Integer> hs = new HashSet<>();

        cnt++;
        hs.add(s);

        boolean flg = true;

        while (flg) {
            int tmp;

            cnt++;

            if (s % 2 == 0) tmp = s / 2;
            else tmp = 3 * s + 1;

            if (hs.contains(tmp)) {
                flg = false;
            }

            hs.add(tmp);

            s = tmp;
        }

        return cnt;
    }

    public static void main(String[] args) throws IOException {
        final String S;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            S = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        int s = Integer.parseInt(S);

        out.println(f(s));

        out.flush();
    }
}


Measured memory_bytes: 21332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

      return tokenizer.nextToken("\n");
    }

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

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

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

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

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

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

  private static int gcd(int a, int b, int c) {
    return gcd(gcd(a, b), c);
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int k = sc.nextInt();
    long sum = 0L;
    for (int a = 1; a <= k; a++) {
      for (int b = 1; b <= k; b++) {
        for (int c = 1; c <= k; c++) {
          sum += (long) gcd(a, b, c);
        }
      }
    }
    System.out.println(sum);
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n, k;
    cin >> n >> k;
    ll h[n];
    NREP() {
        cin >> h[i];
    }
    sort(h, h + n, greater<>());

    REP(i, k) {
        if (i >= n) break;
        h[i] = 0;
    }

    ll ans = 0;
    NREP() {
        ans += h[i];
    }

    MSG(ans)
}


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

using namespace std;

#define MAX 200
#define INF INT_MAX
typedef pair<string,int> P;
typedef vector<string> Vec;

int N;
vector<P> vec;

int cost(Vec v){
  int res = 0;
  for(int i = 0 ; i < (int)v.size() ; i++){
    for(int j = 0 ; j < N ; j++){
      if(vec[j].first == v[i]){
        res += vec[j].second;
        break;
      }
    }
  }
  return res;
}

int main(){
  int M, K;

  while(cin >> N, N){
    map<string,Vec> mp;
    P in; 

    vec.clear();
    for(int i = 0 ; i < N ; i++){
      cin >> in.first >> in.second;
      vec.push_back(in);
    }

    string str, s, item;
    cin >> M;
    for(int i = 0 ; i < M ; i++){
      cin >> str >> K;
      for(int j = 0 ; j < K ; j++){
        cin >> s;
        mp[str].push_back(s);
      }
    }    

    map<string,Vec>::iterator it;
    for(int i = 0 ; i < 2 ; i++){
      for(it = mp.begin() ; it != mp.end() ; ++it){
        for(int j = 0 ; j < N ; j++){
          if(vec[j].first == it->first){
            vec[j].second = min(vec[j].second, cost(it->second));
          }
        }
      }
    }
    cin >> item;
    int ans = INF;
    for(int i = 0 ; i < N ; i++){
      if(vec[i].first == item){
        ans = vec[i].second;
        break;
      }
    }
  
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1228
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))

#define loop(i,n) for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define mci map<char,lli>
#define vi vector<lli>
#define vbool vector<bool>
#define seti set<lli>
#define pii pair<lli,lli>
#define pcc pair<char,char>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n,k;
    cin>>n>>k;
    lli cnt=0;
    loop(i,n){
        ld a,b;
        cin>>a>>b;
        ld ans = sqrt(a*a + b*b);
        if(ans <= k)
            cnt++;
    }
    print(cnt);


  }
return 0;
}


Measured memory_bytes: 3864
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int i, n, blow, hit;
	
	while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF ){
		
		hit = 0;
		blow = 0;
		
		for (i = 0; i < 4; i++){
			scanf("%d", &b[i]);
			if (a[i] == b[i]){
				hit++;
			}
		}
		
		for (i = 0; i < 4; i++){
			for (n = 0; n < 4; n++){
				
				if (a[i] == b[n]){
					blow++;
				}
			}
		}
		blow -= hit;
		
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
}
		

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vint G[111111];

int dfs(int v,int p){
    vint lis;
    for(auto u:G[v]){
        if(u==p)continue;
        lis.pb(dfs(u,v));
    }

    int k=0;
    int ret=0;
    for(auto x:lis)ret|=x;
    rep(i,20){
        int cnt=0;
        for(auto x:lis)if(x>>i&1)cnt++;
        if(cnt>1)k=i+1;
    }
    while(ret>>k&1)k++;
    rep(i,k)if(ret>>i&1)ret^=1<<i;
    ret^=1<<k;
    return ret;
}

signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }
    int tmp=dfs(0,-1);
    int k=20;
    while(~tmp>>k&1)k--;
    cout<<k<<endl;
    return 0;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();
            var ans = 0;
            if (n % 2 != 0)
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                num.Sort((a,b) => b -a);
                for(var i=0;i<n;i++)
                {
                    if(i+1 == n/2)
                    {
                        if(num[i] == num[i+1])
                        {
                            Console.WriteLine(0);
                            return;
                        }
                        ans = num[i] - num[i + 1];
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 26592
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a[]=new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k=sc.nextInt();
System.out.println(a[k-1]);
}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> K;
	int ind0 = 0;
	vector<int> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	ans = 2*(x[N - 1] - x[0]);
	for (int i = 0; i <= N - K; i++) {
		ll tmp;
		if (x[i]>=0)tmp = x[i + K - 1];
		else if (x[i + K - 1] <= 0)tmp = -x[i];
		else tmp = min(-2 * x[i] + x[i + K - 1], -x[i] + 2 * x[i + K - 1]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,m;cin>>m>>n;
  if(m < 10)print(n + 100*(10-m));
  else print(n);
  return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    S = [[0] * W for _ in range(H)]
    for i in range(H):
        S[i] = readline().strip()

    dxdy4 = ((-1, 0), (0, -1), (0, 1), (1, 0))

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                continue
            dist = [[-1] * W for _ in range(H)]
            dist[i][j] = 0
            queue = deque([(i, j)])
            res = 0
            while queue:
                x, y = queue.popleft()
                for dx, dy in dxdy4:
                    nx, ny = x + dx, y + dy
                    if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.' and dist[nx][ny] == -1:
                        dist[nx][ny] = dist[x][y] + 1
                        if res < dist[nx][ny]:
                            res = dist[nx][ny]
                        queue.append((nx, ny))
            if ans < res:
                ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74704
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
#define INF (1<<27)
typedef pair<int,int> _P;
typedef pair<int,_P> P;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int R,L1[100001],L2[100001];
int room1[500][500],W1,H1,X1,Y1;
int room2[500][500],W2,H2,X2,Y2;
bool vst[500][500];
int main() {
	while(scanf("%d",&R),R) {
		scanf("%d %d %d %d",&W1,&H1,&X1,&Y1); X1--; Y1--;
		for(int y=0;y<H1;y++) for(int x=0;x<W1;x++)
			scanf("%d",&room1[x][y]);
		scanf("%d %d %d %d",&W2,&H2,&X2,&Y2); X2--; Y2--;
		for(int y=0;y<H2;y++) for(int x=0;x<W2;x++)
			scanf("%d",&room2[x][y]);
		fill(L1,L1+100001,INF);
		L1[0]=0;
		memset(vst,0,sizeof(vst));
		priority_queue<P,vector<P>,greater<P> > Q;
		Q.push(P(1,_P(X1,Y1)));
		vst[X1][Y1]=true;
		int r=1,l=1;
		while(r<=R&&!Q.empty()) {
			P p=Q.top(); Q.pop();
			l=max(l,p.first);
			L1[r]=l;
			for(int i=0;i<4;i++) {
				int nx=p.second.first+dx[i],ny=p.second.second+dy[i];
				if(0>nx||nx>=W1||0>ny||ny>=H1) continue;
				if(vst[nx][ny]) continue;
				vst[nx][ny]=true;
				Q.push(P(room1[nx][ny],_P(nx,ny)));
			}
			r++;
		}
		fill(L2,L2+100001,INF);
		L2[0]=0;
		memset(vst,0,sizeof(vst));
		priority_queue<P,vector<P>,greater<P> > _Q;
		_Q.push(P(1,_P(X2,Y2)));
		vst[X2][Y2]=true;
		r=1,l=1;
		while(r<=R&&!_Q.empty()) {
			P p=_Q.top(); _Q.pop();
			l=max(l,p.first);
			L2[r]=l;
			for(int i=0;i<4;i++) {
				int nx=p.second.first+dx[i],ny=p.second.second+dy[i];
				if(0>nx||nx>=W2||0>ny||ny>=H2) continue;
				if(vst[nx][ny]) continue;
				vst[nx][ny]=true;
				_Q.push(P(room2[nx][ny],_P(nx,ny)));
			}
			r++;
		}
		int ans=INF;
		for(int i=0;i<=R;i++) ans=min(ans,L1[i]+L2[R-i]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 4356
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  string S;
  cin>>S;
  int N=S.size();

  vector<ll> alp(26,0);
  rep(i,N) alp[S[i]-'a']++;

  ll ans=0;
  rep(i,26){
    ans+=(alp[i])*(N-alp[i]);
  }
  cout<<ans/2+1<<endl;


  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
typedef vector< vector< ll > > Matrix;
Matrix mul(const Matrix &A, const Matrix &B) {
	Matrix C = Matrix(A.size(), vector< ll >(B[0].size(), 0));
	rep(i, C.size())
		rep(k, B.size()) if (A[i][k])
			rep(j, C[0].size())(C[i][j] += A[i][k] * B[k][j] % MOD) %= MOD;
	return C;
}
Matrix unit(int n) {
	Matrix A(n, vector< ll >(n, 0));
	rep(i, n) A[i][i] = 1;
	return A;
}
Matrix pow(const Matrix &A, int n) {
	Matrix B = A;
	Matrix C = unit(A.size());
	while (n) {
		if (n & 1)
			C = mul(C, B);
		B = mul(B, B);
		n >>= 1;
	}
	return C;
}
void printM(const Matrix &A) {
	rep(i, A.size()) {
		rep(j, A[0].size()) {
			cout << A[i][j] << " ";
		}
		cout << endl;
	}
}
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	Matrix M(N, vector< int >(N));
	rep(i, N) rep(j, N) cin >> M[i][j];
	Matrix M2 = pow(M, K);
	int ans = 0;
	rep(i, N) rep(j, N)(ans += M2[i][j]) %= MOD;
	cout << ans << endl;
	return 0;
}

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

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


    int n;cin>>n;
    string s;cin>>s;
    int rcnt=0,wcnt=0;
    for(int i=0;i<n;i++){
      if(s[i]=='R')rcnt++;
      else wcnt++;
    }
    int a=0,b=n-1;
    int ans=0;
    while(1){
      if(a>=b)break;
      while(a<n && s[a]!='W'){
        a++;
      }
      while(b>=0 && s[b]!='R'){
        b--;
      }
      if(a>=b)break;
      ans++;
      a++,b--;
    }
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;
const ll MOD = 1e9+7;


int main(){
	int N;
	ll T[100005]={}, A[100005]={};

	cin >> N;
	rep(i,N) cin >> T[i+1];
	rep(i,N) cin >> A[i+1];

	ll ans = 1;
	rep(i,N+1){
		if( i == 0 ) continue;
		if( T[i-1] == T[i] && A[i] == A[i+1] ){
			auto tmp = min( T[i], A[i] );
			ans *= tmp;
			ans %= MOD;
		}else{
			ll h = -1;
			if( T[i-1] != T[i] ) h = T[i];
			if( A[i] != A[i+1] ){
				if( h == -1 ) h = A[i];
				else if( h != A[i] ) h = -1;
			}
			if( h < 0 ) ans = 0;
			if( h > T[i] || h > A[i] ) ans = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1920