akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << (x) << endl
#define int long long
using namespace std;
using II = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;
class Grid {
  // queryを計算しやすいようにaccの範囲外の値も便宜的に定義
  int acc_any(int i, int j) {
    if (i + j < 0 || H + W - 1 <= i + j) return 0;
    if (i < 0 || j >= W) return 0;
    if (j < 0 && i + j < H) return acc[i + j][0];
    if (i >= H && i + j >= H) return acc[H - 1][i + j - (H - 1)];
    return acc[i][j];
  }
public:
  VVI t; int H, W;
  VVI acc;
  Grid(VVI tbl) : t(tbl), H(tbl.size()), W(tbl[0].size()) {
    set_acc();
  }
  VI& operator[](int i) {
    return t[i];
  }
  bool exist(int i, int j) {
    return 0 <= i && i < H && 0 <= j && j < W && t[i][j];
  }
  // 左下方向への累積和
  void set_acc() {
    acc = VVI(H, VI(W));
    REP (i, H) {
      REP (j, W) {
        int before = (i == 0 || j == W - 1) ? 0 : acc[i - 1][j + 1];
        acc[i][j] = before + t[i][j];
      }
    }
  }
  // 時計回りに90度回転
  void rotate() {
    VVI t2(W, VI(H));
    REP (i, H) {
      REP (j, W) {
        t2[j][H - i - 1] = t[i][j];
      }
    }
    t = move(t2);
    // t = t2;
    swap(H, W);
    set_acc();
  }
  // [i0, i1)の斜めのsum
  int query(int i0, int j0, int i1, int j1) {
    assert(i0 + j0 == i1 + j1);
    assert(i1 > i0);
    return acc_any(i1 - 1, j1 + 1) - acc_any(i0 - 1, j0 + 1);
  }
};
 
signed main() {
  int H, W; cin >> H >> W;
  VVI t(H, VI(W));
  REP (i, H) {
    REP (j, W) {
      t[i][j] = in<char>() == '#';
    }
  }
  Grid g(t);
  int ans = 0;
  int times = 4;
  while (times--) {
    REP (i, g.H) {
      REP (j, g.W) {
        if (!g.exist(i, j)) continue;
        REPI (k, 1, g.H + g.W - 1) {
          if (!g.exist(i + k, j - k)) continue;
          ans += g.query(i + k, j + k, i + 2 * k, j);
        }
      }
    }
    g.rotate();
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 1e5 + 5;
int arr[N], memo[N];

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

	int n;
	cin >> n;
	rep(i, 0, n)
		cin >> arr[i];
	rep(i, n, N)
		memo[i] = arr[i] = 1e9 + 1;

	for (int i = n - 2; i >= 0; i--)
	{
		memo[i] = 2e9;
		memo[i] = min(memo[i], memo[i + 1] + abs(arr[i] - arr[i + 1]));
		memo[i] = min(memo[i], memo[i + 2] + abs(arr[i] - arr[i + 2]));
//		cout << memo[i] << " ";
	}
//	cout << endl;
	cout << memo[0] << endl;

	return 0;
}


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

void solve(){
    ll n ,k; cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
        exit(0);
    }

    n = n%k;
    
    while(true){
        ll tmp = abs(k - n);
        if(tmp < n) n = tmp;
        else break;
    }
    
    cout << n << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int INF = 1e9;

struct SegTree {
    int init, size;
    vector<int> seg;

    // This function is used in query
    int f(int a, int b) {
        return min(a,b);
    }

    // This function is used in update
    int g(int a, int b) {
        return b;
    }

    SegTree(const vector<int>& v, int init = 0) : init{init} {
        size = 1;
        while (size < v.size()) size <<= 1;
        seg.resize(2 * size,init);
        for (int i = 0; i < v.size(); i++) {
            seg[i + size] = v[i];
        }
        for (int i = size - 1; i > 0; i--) {
            seg[i] = f(seg[2 * i], seg[2 * i + 1]);
        }
    }

    SegTree(int n, int init) : SegTree{vector<int>(n,init),init} {}

    SegTree(int n) : SegTree{n,0} {}

    SegTree() {}

    void update(int k, int x) {
        k += size;
        seg[k] = g(seg[k],x);
        k /= 2;
        for (; k > 0; k /= 2) {
            seg[k] = f(seg[2 * k], seg[2 * k + 1]);
        }
    }

    int query(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) return init;
        if (a <= l && r <= b) return seg[k];
        int x = query(a,b,2 * k,l,(l + r) / 2);
        int y = query(a,b,2 * k + 1,(l + r) / 2,r);
        return f(x,y);
    }

    int query(int a, int b) {
        return query(a,b,1,0,size);
    }
};

SegTree st[2];
int p[200000];
int pos[200001];

void f(priority_queue<tuple<int,int,int>>& q, int l, int r) {
    if (l >= r) return;
    int x = st[l % 2].query(l,r);
    q.push(make_tuple(-x,l,r));
}

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n) scanf("%d",&p[i]);

    st[0] = SegTree(n,INF);
    st[1] = SegTree(n,INF);
    REP (i,n) st[i%2].update(i,p[i]);

    REP (i,n) pos[p[i]] = i;

    vector<pair<int,int>> ans;
    priority_queue<tuple<int,int,int>> q;
    q.push(make_tuple(0,0,n));
    while (!q.empty()) {
        int g, l, r;
        tie(g,l,r) = q.top(); q.pop();
        int x = st[l%2].query(l,r);
        int y = st[1-l%2].query(pos[x],r);
        ans.emplace_back(x,y);
        f(q,l,pos[x]);
        f(q,pos[x] + 1,pos[y]);
        f(q,pos[y] + 1,r);
    }
    for (auto p: ans) {
        printf("%d %d ",p.first,p.second);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 9468
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [LIST() for i in range(N-1)]
graph = defaultdict(list)
edge = defaultdict(int)

for a, b in L:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

K = 0
# 子の数が最大となるものの子の数が，塗れる色の最大値
for v in graph.values():
    K = max(K, len(v))

# this is color pallet
color = list(range(1, K + 1))
# color = [1, ..., K]
q = deque()
q.append((0, None))
while q:
    i, color_from = q.popleft()
    tmp = -1
    # colorの後ろから見れるように
    for node in graph[i]:
        str_ = "{},{}".format(i, node)
        # まだedge辞書になければ
        if not edge[str_]:
            use_color = color[tmp]
            if use_color == color_from:
                # さらに小さい色のやつ
                tmp -= 1
                use_color = color[tmp]
            # 次対策
            tmp -= 1
            edge[str_] = use_color
            edge["{},{}".format(node, i)] = use_color
            q.append((node, use_color))
print(K)
for a, b in L:
    print(edge["{},{}".format(a-1, b-1)])



Measured memory_bytes: 80804
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}








int main(){
  int N;
  cin>>N;
  int a[N];
  int yon=0;
  int kisuu=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    if(a[i]%4==0){
      yon++;
    }
    if(a[i]%2==1){
      kisuu++;
    }
  }
  if(N-yon-kisuu>0){
  if(yon>=kisuu){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}else{
  if(yon+1>=kisuu){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
  

}



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

flag = False
res = 1

while res < 1010:
    res_a = int(res * 0.08)
    res_b = int(res * 0.10)
    if res_a == A and res_b == B:
        flag = True
        break
    res += 1

if flag:
    print(res)
else:
    print(-1)


Measured memory_bytes: 38356
#include<iostream>
#include<string>
#include <stdio.h>

using namespace std;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  for(int i = 0;i<k;i++){
    if(a>=b&&a>=c){
      a = 2*a;
      continue;
    }
    else if(b>=a&&b>=c){
      b = 2*b;
      continue;
    }
    else{
      c=c*2;
      continue;
    }
  }
  cout << a+b+c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int n,a,b,c,ans = 1<<30;
vector<int> l;

int cal(vector<int> g){
  int aa = 0, bb = 0, cc = 0, p = 0;
  for(int i = 0; i < n; i++){
    if(g[i] == 0){
      aa += l[i];
    }else if(g[i] == 1){
      bb += l[i];
    }else if(g[i] == 2){
      cc += l[i];
    }
    if(g[i] != 3) p += 10;
  }
  if(aa == 0 || bb == 0 || cc == 0) return 1<<30;
  p += abs(aa-a);
  p += abs(bb-b);
  p += abs(cc-c);
  p -= 30;
  return p;
}

void dfs(vector<int> g){
  if(g.size() == n){
    int p = cal(g);
    ans = min(ans,p);
    return;
  }
  for(int i = 0; i < 4; i++){
    g.push_back(i);
    dfs(g);
    g.pop_back();
  }
}

int main(){
  cin >> n >> a >> b >> c;
  l.resize(n);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  vector<int> g;
  dfs(g);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    map<int, int> cnt;
    rep(i, n){
        int a; cin >> a;
        cnt[a]++;
    }

    int m; cin >> m;
    string res = "YES";
    rep(i, m){
        int a; cin >> a;
        cnt[a]--;
        if(cnt[a] < 0){
            res = "NO";
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 (b<a) { a=b; return 1; } return 0; }

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


    int n;cin>>n;
    vector<complex<long double>> v(n);
    rep(i,n){
        long double x,y;
        cin>>x>>y;
        v[i]=complex<long double>(x,y);
    }
    sort(ALL(v),[&](complex<long double> a,complex<long double> b){
        return arg(a)<arg(b);
    });
    long double ans=0;
    rep(i,n){
        long double x=0,y=0;
        rep(j,n){
            x+=real(v[(i+j)%n]);
            y+=imag(v[(i+j)%n]);
            chmax(ans,sqrt(x*x+y*y));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
   cin>>n;
   ll ar[n],br[n];
  rep(i,0,n)
  {
    cin>>ar[i]>>br[i];
  }
  rep(i,0,n)
  {
    if(ar[i]==br[i]) k++;
    else k=0;
    if(k==3){ cout<<"Yes";return ;}
  }
  cout<<"No";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

template< typename T >
struct edge {
    int src,to;
    T cost;

    edge() = default;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

////////////////////////////////////////////////////////////////////////

template<typename T>
vector<T> Dijkstra(vector<vector<edge<T>>> &G, int s, T inf) {
    vector<T> dist(G.size(),inf);

    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> pq;
    dist[s] = 0;
    pq.emplace(dist[s],s);
    while (!pq.empty()) {
        T d; int v;
        tie(d,v) = pq.top(); pq.pop();
        if (d > dist[v]) continue;
        for (auto &e : G[v]) {
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                pq.emplace(dist[e.to],e.to);
            }
        }
    }

    return dist;
}

//////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M,s; cin >> N >> M >> s;
    vector<vector<edge<ll>>> G(N);
    for (int i = 0; i < M; ++i) {
        ll u,v,d; cin >> u >> v >> d;
        G[u].emplace_back(v,d);
    }

    auto dist = Dijkstra<ll>(G,s,1e18);
    for (int i = 0; i < N; ++i) {
        if (dist[i] == 1e18) {
            cout << "INF" << endl;
        } else cout << dist[i] << endl;
    }
}

/*
  verified on 2020/02/09
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=ja
*/


Measured memory_bytes: 19448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = int.Parse(Console.ReadLine());
		var result = Console.ReadLine().Split().Select(v => int.Parse(v)).Where((v, i) => (i+1) % 2 == 1 && v % 2 == 1).Count();
		Console.WriteLine(result);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 28028
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

using ull = unsigned long long;
using ll = long long;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;
  map<ll,ll> m;

  rep(i,n)
  {
    ll b = 0;
    cin >> b;
    m[b]++;
  }
  ll ans = 0;
  for(auto itr = m.begin();itr != m.end();itr++)
  {
    auto a = m.find(itr->first - 1);
    auto b = m.find(itr->first);
    auto c = m.find(itr->first + 1);
    ll p = (a != m.end()) ? a->second : 0;
    ll q = (b != m.end()) ? b->second : 0;
    ll r = (c != m.end()) ? c->second : 0;
    ans = max(ans,p + q + r);
  }


  cout << ans << endl;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 4224
// Grid Repainting
// 所要時間 分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int h, w;
    cin >> h >> w;
    vector<vector<char>> graph(h, vector<char>(w));
    int cnt = 0;
    rep(i, h){
        rep(j, w){
            cin >> graph[i][j];
            if(graph[i][j] == '.'){
                cnt++;
            }
        }
    }

    queue<P> q;
    vector<vector<int>> dis(h, vector<int>(w, -1));
    q.push({0, 0});
    dis[0][0] = 1;

    const int dy[] = {1, 0, -1, 0};
    const int dx[] = {0, 1, 0, -1};
    while(!q.empty()){
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        rep(i, 4){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w){
                continue;
            }
            if(graph[ny][nx] == '#'){
                continue;
            }
            if(dis[ny][nx] == -1){
                dis[ny][nx] = dis[y][x] + 1;
                q.push({ny, nx});
            }
        }
    }
    if(dis[h-1][w-1] == -1){
        cout << -1 << endl;
    }
    else{
        cout << cnt - dis[h-1][w-1] << endl;
    }

    return 0;
}

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

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

	sort( s.begin(), s.end() );
	sort( t.begin(), t.end(), greater<char>() );
	string ans = "No";
	if( t > s ) ans = "Yes";

	cout << ans << endl;
}


Measured memory_bytes: 3604
from itertools import product
# 微妙にわからない
N = int(input())
B = list(product([1, 0], repeat=N))
L = []
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        L.append([x, y, i+1])
ans = 0
for b in B:
    for l in L:
        if b[l[2]-1] == 1 and l[1] != b[l[0]-1]:
            break
    else:
        if ans < b.count(1):
            ans = b.count(1)
print(ans)


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

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

    int cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (x == 500*i + 100*j + 50*k) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
#define cons 1000000007 
using namespace std;


signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, i, j, ii;
    cin>>n;
    int a[n], p[n];
    for(i=0;i<n;i++)
        cin>>p[i];
    for(i=0;i<n;i++){
        for(j=i;j<n;j++){
            for(ii=0;ii<n;ii++)
                a[ii]=p[ii];
            int t = a[i];
            a[i]=a[j];
            a[j]=t;
            int c = 0;
            for(ii=0;ii<n-1;ii++){
                if(a[ii]>a[ii+1])
                    c++;
            }
            if(c==0)
            {
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;

}




Measured memory_bytes: 256
<?php
list($h, $w) = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $h; $i++){
    $line = trim(fgets(STDIN));
    for($j = 0; $j < $w; $j++){
        $map[$i][$j] = $line[$j];
    }
}
$flag = true;
for($i = 0; $i < $h; $i++){
    for($j = 0; $j < $w; $j++){
        if($map[$i][$j] == "#"){
            if(isset($map[$i+1][$j]) && $map[$i+1][$j] == "#")continue;
            if(isset($map[$i-1][$j]) && $map[$i-1][$j] == "#")continue;
            if(isset($map[$i][$j+1]) && $map[$i][$j+1] == "#")continue;
            if(isset($map[$i][$j-1]) && $map[$i][$j-1] == "#")continue;
            $flag = false;
        }
    }
}
echo $flag ? "Yes":"No";


Measured memory_bytes: 4728
#include<iostream>
using namespace std;
char a[105][105];
int main()
{
	int n,m,i,j,s=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	for(j=1;j<=m;j++)cin>>a[i][j];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
		s=0;
			if(a[i][j]=='#')cout<<"#";
			else if(a[i][j]=='.')
			{
				if(a[i-1][j-1]=='#')s++;
				if(a[i-1][j]=='#')s++;
				if(a[i-1][j+1]=='#')s++;
				if(a[i][j-1]=='#')s++;
				if(a[i][j+1]=='#')s++;
				if(a[i+1][j-1]=='#')s++;
				if(a[i+1][j]=='#')s++;
				if(a[i+1][j+1]=='#')s++;
				cout<<s;
			}
		}
		cout<<endl;
	}
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
  long N;
  cin >> N;

  unordered_map<long, long> nums;

  long sum = 0;
  vector<long> inputs;
  inputs.reserve(N);
  for (size_t n = 0; n < N; ++n) {
    long A;
    cin >> A;
    inputs.push_back(A);
    ++nums[A];
  }
  vector<pair<long, long>> num_pairs(nums.begin(), nums.end());
  sort(num_pairs.begin(), num_pairs.end(), [](const pair<long, long>& lhs, const pair<long, long>& rhs) {
    return lhs.first > rhs.first;
  });
  for (long a : inputs) {
    if (a != num_pairs[0].first || (a == num_pairs[0].first && num_pairs[0].second > 1)) {
      cout << num_pairs[0].first << endl;
    } else {
      cout << num_pairs[1].first << endl;
    }
  }
    
  return 0;
}

Measured memory_bytes: 9636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define EVEL 1
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    int A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    //string S;
    bool S[101][101];
    int temp[100]={0};
    bool f=true;
    bool fir=true;

int main(){
    cin>>W>>H>>N;

    REP(i,H){
        REP(j,W){
            S[i][j]=true;
        }
    }
    REP(i,N){
        cin>>X>>Y>>A;
        if(A==1){
            //x<xi
            REP(j,H){
                REP(k,X){
                    S[j][k]=false;
                }
            }
        }
        else if(A==2){
            REP(j,H){
                FOR(k,X,W){
                    S[j][k]=false;
                }
            }
        }
        else if(A==3){
            REP(j,W){
                REP(k,Y){
                    S[k][j]=false;
                }
            }
        }
        else if(A==4){
            REP(j,W){
                FOR(k,Y,H){
                    S[k][j]=false;
                }
            }
        }
        REP(i,H){REP(j,W){
            DEB(S[i][j])
        }END}
        END
    }
    REP(i,H)
        REP(j,W){
            S[i][j]?ans++:ans=ans;
        }
    cout<<ans;
}
/*A.size()!=0&&B.size()!=0&&C.size()!=0*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[2][N];
pll val[N];
ll pre[N];
int main()
{
       int n,k;
       cin>>n>>k;
       map<pair<int,int>,int> mp;
       for(ll i = 1 ; i*i <= n ; i++)
       {
              mp[mkp(i,i)] = n/i;
              mp[mkp((n/(i+1))+1,n/i)] = i;
       }
       unordered_map<int,int> mp1;
       int ii = 0;
       val[0] = {0,0};
       tra(it,mp){
              mp1[it->fr.sc] = ii;
              val[ii++].fr = it->sc;
              val[ii-1].sc = it->fr.sc-it->fr.fr+1;
       }
       fri(i,0,ii){
              dp[0][i] = val[i].sc;
       }
       fri(i,1,k){
              dp[1][0] = dp[0][0];
              fri(j,1,ii){
                     dp[1][j] = (dp[1][j-1] + dp[0][j])%mod;
              }
              fri(j,0,ii){
                     dp[0][j] = (val[j].sc*(dp[1][mp1[val[j].fr]]))%mod;
              }
       }
       dp[1][0] = dp[0][0];
       fri(j,1,ii){
              dp[1][j] = (dp[1][j-1] + dp[0][j])%mod;
       }
       cout<<dp[1][ii-1]<<endl;
}


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

signed main() {
    int N, C;
    cin >> N >> C;
    bool table[C][100001] = {};
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        for (int j = s; j <= t; j++) {
            table[c - 1][j] = true;
        }
    }
    int max_score = 0;
    for (int i = 0; i < 100001; i++) {
        int cur = 0;
        for (int j = 0; j < C; j++) {
            if (table[j][i]) {
                cur++;
            }
        }
        max_score = max(max_score, cur);
    }
    cout << max_score << endl;
    return 0;
}


Measured memory_bytes: 3200
N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
for i in range(N):
	ans = ans * T[i] // gcd(ans, T[i])
	
print(ans)

Measured memory_bytes: 38520
#include <bits/stdc++.h>
#define inf 2333333333333333
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)

using namespace std;
int n,m;
typedef pair<int,int>P;
queue<P>q;
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    in(n);
    For(i,1,n){
        For(j,i+1,n){
            if(j!=n-i+(n%2==0?1:0)){
                m++;
                q.push(P(i,j));
            }
        }
    }
    o(m);p('\n');
    while(!q.empty()){
        auto k=q.front();q.pop();
        o(k.first);p(' ');o(k.second);p('\n');
    }
    return 0;
}

Measured memory_bytes: 3652
from itertools import product
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0 for _ in range(M+1)])
flag = 0
for j in range(1,M+1):
    cnt = 0
    for i in range(1,N+1):
        cnt += A[i][j]
    if cnt<X:
        flag = 1
        break
if flag==1:
    cost = -1
else:
    cost = 10**7
    for x in product((0,1),repeat=N+1):
        if x[0]==0:
            flag1 = 0
            for j in range(1,M+1):
                cnt = 0
                for i in range(1,N+1):
                    if x[i]==1:
                        cnt += A[i][j]
                if cnt<X:
                    flag1=1
                    break
            if flag1==0:
                cnt = 0
                for i in range(1,N+1):
                    if x[i]==1:
                        cnt += A[i][0]
                cost = min(cost,cnt)
print(cost)

Measured memory_bytes: 73820
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int ma[55][55] = {}, in[55][55];

signed main(void) {
    int w,h,tm;
    cin >> w >> h >> tm;
    int q;
    cin >> q;
    vi x(q),y(q),t(q);
    rep(i,q)cin >> x[i] >> y[i] >> t[i];
    rep(i,h)rep(j,w)cin >> in[i][j];
    rep(i,q){
        int b = x[i];
        int a = y[i];
        if(in[a][b])ma[a][b]++;
    }
    int ans = 0;
    rep(i,h)rep(j,w)ans += ma[i][j];
    cout << ans << endl;
}



Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int k = s.size();
	cout << s[0] << k - 2 << s[k - 1] << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll x = in(), t = in();
	cout << max(0ll, x - t) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int a = Integer.valueOf(str.substring(0,2));
        int b = Integer.valueOf(str.substring(2,4));
        
        if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
            System.out.println("AMBIGUOUS");
        } else if (0 <= a && a <= 99 && 1 <= b && b <= 12) {
            System.out.println("YYMM");
        } else if (0 <= b && b <= 99 && 1 <= a && a <= 12) {
            System.out.println("MMYY");
        } else {
            System.out.println("NA");
        }
    }
}

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

int main(void)
{
    long long mod = 1000000007;
    long long N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    vector<char> S1(N);
    vector<char> S2(N);
    for (long long i = 0; i < N; i++)
    {
        S1[i] = s1[i];
    }
    for (long long i = 0; i < N; i++)
    {
        S2[i] = s2[i];
    }
    
    long long ans;
    if (S1[0] == S2[0])
    {
        ans = 3;
    }
    else
    {
        ans = 6;
    }

    for (long long i = 1; i < N; i++)
    {
        if (S1[i] == S2[i])
        {
            if (S1[i-1] == S2[i-1])
            {
                ans = ans * 2 % mod;
            }
        }
        else
        {
            if (S1[i-1] == S2[i-1])
            {
                ans = ans * 2 % mod;
            }
            else if (S1[i-1] != S1[i] && S2[i-1] != S2[i])
            {
                ans = ans * 3 % mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    String[]S = new String[n]; 

    for(int i=0; i<n; i++) {
    	S[i] = sc.next();
    }
    Arrays.sort(S); 
    for(int i=0; i<n; i++) {
    	System.out.print(S[i]);
    }
}
}


Measured memory_bytes: 37324
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
//________
#define pb emplace_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__ )
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
constexpr int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
typedef long long ll;
typedef pair<int,int> pii;
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
#define let const auto
//________

int H, W;
char mp[55][55];
int d[55][55];

//fi:Y  se:X

int bfs() {
   queue <pii> que;
   que.push( pii(0,0) );
   memset(d, INF, sizeof(d) );
   d[0][0] = 0;

   while (!que.empty()) {
      let tmp = que.front(); que.pop();
      if (tmp.fi == H-1 && tmp.se == W-1) {
         return (d[tmp.fi][tmp.se]);
      }

      rep(i, 4) {
         let nx = tmp.se + dx[i];
         let ny = tmp.fi + dy[i];

         if (inside(nx,ny,W,H) && mp[ny][nx] != '#' && d[ny][nx] == INF) {
            d[ny][nx] = d[tmp.fi][tmp.se] + 1;
            que.push( pii(ny,nx) );
         }
      }
   }
   return (d[H-1][W-1]);
}

signed main()
{
   FAST();
   cin >> H >> W;
   int cnt = 0;

   rep(i, H) {
      rep(j, W) {
         cin >> mp[i][j];
         if (mp[i][j] == '#') {
            ++cnt;
         }
      }
   }

   int res = bfs();
   outl( res == INF ? (-1) : (H*W - cnt - res - 1) );
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[200200];
li b[200200];
li aa[200200];
li bb[200200];
li n;



int main() {
    cin >> n;
    vector<li> v;
    rin{
        cin >> a[i] >> b[i];
        a[i] *= 2;
        b[i] *= 2;
        v.pb(a[i]);
        aa[i] = a[i];
        bb[i] = b[i];
    }
    sort(allof(v));
    sort(aa, aa + n);
    sort(bb, bb + n);
    li base = -1;
    if (n % 2 == 0) {
        base = (v[n / 2] + v[n / 2 - 1]) / 2;
        li lower = (aa[n / 2] + aa[n / 2 - 1]) / 2;
        li upper = (bb[n / 2] + bb[n / 2 - 1]) / 2;
        cout << (upper - lower + 1) << endl;
    } else {
        base = v[n / 2];
        li lower = aa[n / 2] / 2;
        li upper = bb[n / 2] / 2;
        cout << (upper - lower + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 11216
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let [| N; M; K |] = reada int

    seq {
        for n in 0 .. N do
            for m in 0 .. M do
                let a = m * (N - n) + n * (M - m)
                if a = K then yield ()
    }
    |> fun s ->
        if Seq.isEmpty s then "No"
        else "Yes"
    |> printfn "%s"
    0 // return an integer exit code


Measured memory_bytes: 14168
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
int N, A, B, P[100+5] = {0};
int q1 = 0, q2 = 0, q3 = 0;
cin >> N >> A >> B;

for(int i = 0; i < N; i++){
    cin >> P[i];
}

for(int i = 0; i < N; i++){
    if(P[i] <= A) q1++;
    else if (P[i] <= B) q2++;
    else q3++;
}
int ans = min(q1, q2);
ans = min(ans, q3);

cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <string>
#include <stack>
#include<stdio.h>
#include <queue> 
#include <functional>
#define rep(i,n) for (int i=0; i < (int)(n); i++)


using namespace std;

int main(){
	
	stack<int> st; // スタックを宣言＋初期化
	
	int a,b,c,d,e,num;
	int i,j,k;
	int arr[100];
	int arr2[100][100];
	char crr[100];
	char crr2[100][100];
	string str;
	stack<int> istk; // 整数値を格納するスタックを宣言
    stack<string> sstk; // 文字列を格納するスタックを宣言	
	queue<int> ique; // 整数値を格納するキューを宣言
    queue<string> sque; // 文字列を格納するキューを宣言

	while(scanf("%d %d" ,&a , &num) == 2){
	

	
	
	cout << a+num << endl;
	
	}
		
	return 0;
		
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> Tree(N);
	vector<int> Root(N);
	vector<int> Parent(N);
	int r = 0;
	for (int i = 0; i < N + M - 1; i++) {
		int A, B;
		cin >> A >> B;
		Tree[A - 1].push_back(B - 1);
		Root[B - 1]++;
		while (Root[r] > 0) r++;
	}
	queue<int> Q;
	Q.push(r);
	while (!Q.empty()) {
		int v = Q.front();
		Q.pop();
		for (int u : Tree[v]) {
			Root[u]--;
			if (Root[u] == 0) {
				Q.push(u);
				Parent[u] = v + 1;
			}
		}
	}
	for (int p : Parent) cout << p << endl;
}

Measured memory_bytes: 7040
import math

N,K=map(int,input().split())
A=list(map(int, input().split()))
l=0
r=max(A)
while not l+1==r:
    x=(r+l)//2
    k=0
    for a in A:
        k+=math.ceil(a/x)-1
    if k<=K:
        r=x
    else:
        l=x
print(r)

Measured memory_bytes: 31244
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	vi dp(n + 1, -1);	// store the last number of each sequences
	dp[n - 1] = a[0];	// last number of 1st sequence
	dp[n] = INF;

	int cur = n - 1;
	for(int i = 1; i < n; i++) {
		int j = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
		if(j == cur) dp[--cur] = a[i];	// can't add a[i] to existed sequence, so add a sequence
		else dp[j - 1] = a[i];	// update the last number of the sequence where a[i] is added
	}
	cout << n - cur << endl;
}


Measured memory_bytes: 1024
N=int(input())
A=[int(x) for x in input().split()]

flg=0
ans=1

for i in range(N-1):
  if flg==0 and A[i]>A[i+1]:
    flg=-1
  elif flg==0 and A[i]<A[i+1]:
    flg=1
  elif flg==1 and A[i]>A[i+1]:
    flg=0
    ans+=1
  elif flg==-1 and A[i]<A[i+1]:
    flg=0
    ans+=1
  else:
    continue
print(ans)

Measured memory_bytes: 14224