akhauriyash/Code-Regression huggingface dataset:
//
// Created by Hideaki Imamura on 2020-03-25.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

void print_vec(vector<int> v) {
    for (auto x : v) cout << x << " ";
    cout << endl;
}

string s, t;
int last[26];
int nxt[26][500000];

int main() {
    cin >> s >> t;
    /* 頭からtを見ていき、各t[i]がs内で登場するかどうか見る
     * 登場しないなら、存在しないことになる
     * 各ch = t[i]とs'の添字jに対して、x = j mod len(s) として、
     * f(ch, x) = sにおいてx文字目以降でchがはじめに登場する位置
     * を計算できればOKっぽい
     * f(ch, x)は、各アルファベットの出現位置のリストを計算しておくと
     * リストからx以上の最小元を取り出すことになるので、lower_boundでいけそう。
     *
     * x が sの長さより長いなら、一周するということ
     * そうでなくでも、ansには次の位置 - 現在の位置を加えれば良さそう。
     * 次の位置はsの長さ未満にしておく
     */

    s += s;
    int n = s.size(), m = t.size();
    vector<ll> l[26];
    for (int i = 0; i < n; ++i) l[s[i] - 'a'].push_back(i);
    for (int i = 0; i < 26; ++i) l[i].push_back(INF);

    auto f = [&](int ch, ll x) {
        return *lower_bound(l[ch].begin(), l[ch].end(), x);
    };

    fill(last, last + 26, n);
    for (int i = n - 1; i >= n / 2; i--)
    {
        last[s[i] - 'a'] = i;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++) nxt[j][i] = last[j];
        last[s[i] - 'a'] = i;
    }

    ll ans = 0;
    ll x = n / 2 - 1;
    for (int i = 0; i < m; ++i) {
        //ll j = f(t[i] - 'a', x);
        ll j = nxt[t[i] - 'a'][x];
        if (j == n) {
            cout << -1 << endl;
            return 0;
        }
        //cout << ans << " : " << j + 1 << " : " << x << endl;
        ans += j - x;
        x = j % (n / 2);
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50944
/**       In the name of Allah, the Gracious, the Merciful.
*               Praise be to Allah, Lord of the Worlds.
*               **************************************
*
*    I have not failed, I have just found 1000 WAYS that won't work.
*                 __________________________________
*                  Author  : Abd El-Twab  M. Fakhry
*                 __________________________________
*/

#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define  read(arr, l, r)     for(int i = (l); i < (r); cin >> arr[i++])
#define  print(arr, l, r)    for(int i = (l); i < (r); cout << arr[i++] << " \n"[i == r])
#define  rep(i, l, r)        for (int i = l; i < r; i++)
#define  repr(i, r, l)       for (int i = r; i > l; i--)
#define  trav(a, x)          for (auto & a : x)
#define  PQ(T)               priority_queue < T, vector <T> , greater <T> >
#define  Unique(n)           (n).erase(unique(all(n)), (n).end())
#define  endl                '\n'
#define  all(a)              a.begin() , a.end()
#define  NumberOfDigits(n)   ((int)log10(n) + 1)
#define  sz(a)               (int)a.size()
#define  rall(a)             a.rbegin(), a.rend()
#define  rsz(sz)             resize(sz)
#define  ins(x)              insert(x)
#define  debug(x)            cout << #x << " = " << (x) << '\n'
#define  LINE_ON             cout << "line Number = " << __LINE__ << endl
#define  RT(n)               return cout << (n) << endl, 0;
#define  clr(arr, x)         memset(arr, x, sizeof(arr))
#define  F                   first
#define  S                   second
#define  PB                  push_back
#define  EB                  emplace_back
#define  get(n)              find_by_order(n)
#define  indexOf(n)          order_of_key(n)
#define  isPowerOfTwo(x)     (x && !(x & (x - 1)))
#define  Swap(n, k)           n ^= k, k ^= n, n ^= k;

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

template <class T>
using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
typedef long long            ll;
typedef unsigned int         uint;
typedef unsigned long long   ull;

int Dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 }, Dx4[4] = { 0, 0, 1,-1};
int Dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 }, Dy4[4] = { 1,-1, 0, 0};

const double inf  = 1.0 / 0.0,      pi  = 2 * acos(0.0),   error = 1e-9;
const int    MxsZ = (int)2e5 + 6,   mod = (1 << 30) + 7,      oo = 0x3f3f3f3f;

ll Gcd(ll a, ll b)     { return b ? Gcd(b, a % b) : a; }
ll Lcm(ll a, ll b)     { return a * b / Gcd(a, b); }

void Fast()
{
    cin.sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin.exceptions(cin.failbit);
}

void File()
{
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
}

/**----------------------->>  Template  <<-----------------------**/

double n;

/**------------------>>  Initialization gap  <<------------------**/

int main()
{
    Fast();

    cin >> n;
    cout << fixed << setprecision(10) << ((int)n / 2 + ((int)n & 1)) / n << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <set>
#include <string>
#include <iterator>
#include <queue>
#include <cmath>
#include <cassert>

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

int main ()
{
    int P,Q,R;
    cin >> P >> Q >> R;

    vector < int > a = {P, Q, R};
    sort(a.begin(), a.end());

    cout << a[0] + a[1] << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
for i in range(1, 3501):
    for j in range(1, 3501):
        tmp = 4 * i * j - N * j - N * i
        if tmp != 0 and (N * i * j) % tmp == 0:
            k = (N * i * j) // (4 * i * j - N * j - N * i)
            if k>0:
                print(i, j, k)
                exit()


Measured memory_bytes: 69796
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

from collections import defaultdict
from pprint import pprint

A = [int(x) for x in input().split(" ")]
B = {}
for a in A:
    B[a] = 1

if B.get(1) and B.get(7) and B.get(9) and B.get(4):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 22416
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint a, b;
    cin >> a >> b;
    if (a == b) {
        cout << 1 << "\n";
        return 0;
    }
    vector<pair<lint, lint>> seg;
    int firstdiff = -1;
    int secondbit = -1;
    for (int i = 60; i >= 0; --i) {
        int ab = a >> i & 1;
        int bb = b >> i & 1;
        if (firstdiff == -1 && ab != bb) {
            firstdiff = i;
        } else if (firstdiff != -1 && b >> i & 1) {
            secondbit = i;
            break;
        }
    }
    a &= (1LL << (firstdiff + 1)) - 1;
    b &= (1LL << (firstdiff + 1)) - 1;
    seg.emplace_back(a, -1);
    seg.emplace_back(b, 1);
    seg.emplace_back(a, -1);
    seg.emplace_back((1LL << firstdiff) - 1, 1);
    seg.emplace_back((1LL << firstdiff) + a, -1);
    seg.emplace_back((1LL << firstdiff) + (1LL << firstdiff) - 1, 1);
    seg.emplace_back((1LL << firstdiff), -1);
    seg.emplace_back((1LL << firstdiff) + (1LL << secondbit) - 1 + (1LL << secondbit), 1);
    lint ret = 0;
    sort(seg.begin(), seg.end());
    int depth = 0;
    lint curr = 0;
    for (auto &p : seg) {
        if (depth == 0)
            curr = p.first;
        depth -= p.second;
        if (depth == 0) {
            ret += p.first - curr + 1;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;

int N,M,Q;
vector<ll> a,b,c,d;
ll score=0;

void dfs(vector<int> &A){
    if(A.size()==N){
        //rep(i,N)cout<<A[i]<<" ";
        ll sum=0;
        rep(i,Q)if(A[b[i]-1]-A[a[i]-1]==c[i])sum+=d[i];
        score=max(score,sum);
        //cout<<score<<endl;
        return;
    }
    int prev_last=(A.empty()?1:A.back());
    for(int i=prev_last;i<=M;i++){
        A.push_back(i);
        dfs(A);
        A.pop_back();
    }
}
int main(){
    cin>>N>>M>>Q;
    a=b=c=d=vector<ll>(Q);
    rep(i,Q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int> A;
    dfs(A);
    cout<<score<<endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int k,n,a;
    cin>>k>>n;
    std::deque<long long int> house;
    std::deque<long long int> dis;
    long long int max_dis=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        house.emplace_back(a);
        if (i!=0) {
            dis.emplace_back(house[i]-house[i-1]);
            if (house[i]-house[i-1]>max_dis) {
                max_dis=house[i]-house[i-1];
            }
            if (i==n-1) {
                dis.emplace_back(k-a+house[0]);
                if (k-a+house[0]>max_dis) {
                    max_dis=k-a+house[0];
                }
            }
        }
    }
    /*
    for (int hoge=0;hoge<dis.size();hoge++) {
        cout<<dis[hoge]<<" ";
    }
    cout<<endl;
    */
    long long int sum=0;
    for (int j=0;j<dis.size();j++) {
        sum+=dis[j];
    }
    cout<<sum-max_dis<<endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    vector< long long > t(5);
    for (int i = 0; i < 5; i++) {
        cin >> t[i];
    }

    // cout << "min: " << *min_element(t.begin(), t.end()) << endl;
    if (N % *min_element(t.begin(), t.end()) == 0) {
        cout << 5 + N / *min_element(t.begin(), t.end()) - 1 << endl;
    } else {
        cout << 5 + N / *min_element(t.begin(), t.end()) << endl;
    }
}

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


int main(){
	int a,x,MN=1e9;
	string s;
	cin >> s;
	for(int i=0;i<s.size()-2;i++){
		a=0;
		for(int j=i;j<i+3;j++){
			char ch=s[j];
			a=a*10+(ch-'0');
		}
		x=abs(753-a);
		if(x<MN) MN=x;
	}
	
	cout << MN << endl;
	return 0;
}

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

using namespace std;

#define int long long
typedef long long ll;

const ll inf = 1e18;

ll S = 0;
ll N, P, Q;
vector<ll> C;
vector<ll> v;
ll f(ll t) {
	ll res = (t * (t - 1) / 2) * 2 * P + S;
	for (int i = 0; i < t; ++i) {
		res += v[i];
	}
	return res;
}
signed main() {
	cin >> N >> P >> Q;
	C.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
	}

	S = 0;
	for (int i = 0; i < N; ++i) {
		S += C[i];
	}
	for (int i = 0; i < N; ++i) {
		v.push_back((Q - i) * P - C[i]);
	}
	sort( v.begin(), v.end(), greater<ll>() );

	ll now = S;
	ll ans = now;
	for (int i = 0; i < N; ++i) {
		now += i * 2 * P;
		now += v[i];
		ans = max(ans, now);
	}
	cout << ans << endl;

	/*
	ll l = 0, r = N;
	for (int t = 0; t < 100; ++t) {
		ll m1 = l+(r-l)/3, m2 = l+(r-l)*2/3;
		if ( f(m1) < f(m2) ) {
			l = m1;
		}
		else if ( f(m1) > f(m2) ) {
			r = m2;
		}
		else if ( f(l) < f(m1) ) {
			l = m1;
		}
		else {
			r = m2;
		}
	}
	assert(m2-m1 < 3);
	*/
	/*
	ll ans = l;
	for (ll i = l; i <= r; ++i) {
		if ( f(i) > f(ans) ) ans = i;
	}
	*/
//	cout << f(1) << endl;
//	cout << ans << " " << f(ans) << endl;
//	cout << f(ans) << endl;
}

Measured memory_bytes: 11164
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, c;
  cin>>a>>b>>c;
  a = __gcd(b, a);
  cout<<(c%a==0?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i].first >> data[i].second;
    }
    sort(data.begin(), data.end());
    int x = data.back().second;
    int t = data.back().first;
    cout << x + t << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S, T;
  cin >> S >> T;
  bool found = false;
  for (ll i = S.size() - 1; i >= 0; --i) {
    if (i + T.size() > S.size()) {
      continue;
    }
    bool ok = true;
    for (ll j = 0; j < T.size(); ++j) {
      if (S.at(i + j) != '?' && S.at(i + j) != T.at(j)) {
        ok = false;
      }
    }
    if (ok) {
      found = true;
      for (ll j = 0; j < T.size(); ++j) {
        S.at(i + j) = T.at(j);
      }
      break;
    }
  }
  if (!found) {
    cout << "UNRESTORABLE" << "\n";
  }
  else {
    for (ll i = 0; i < S.size(); ++i) {
      if (S.at(i) == '?') {
        S.at(i) = 'a';
      }
    }
    cout << S << "\n";
  }
}


Measured memory_bytes: 3628
<?php
$num = trim(fgets(STDIN));
$input = trim(fgets(STDIN));
$array = explode(" ", $input);
krsort($array);
$array = array_values($array);
for($i = 0; $i <= $num-1; $i++){
    echo $array[$i];
    if($i < $num-1){
        echo " ";
    }
}
?>

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

using namespace std;

#define int long long
#define pb push_back

const int N = 2e5 + 5;
int n, K, a[N];

struct It {
    struct Node {
        int ans, sum;
        vector<int> left, right;
        Node() {
            ans = sum = 0;
            left.clear(); right.clear();
        }
        Node(int val) {
            ans = (val >= 0); sum = val;
            left.pb(val); right.pb(val);
        }
        Node operator + (const Node& rhs) const {
            Node ret;
            ret.ans = ans + rhs.ans; ret.sum = sum + rhs.sum;
            for (int i : left) ret.left.pb(i);
            for (int i : rhs.left) ret.left.pb(sum + i);
            for (int i : rhs.right) ret.right.pb(i);
            for (int i : right) ret.right.pb(rhs.sum + i);
            sort(ret.left.begin(), ret.left.end() );
            sort(ret.right.begin(), ret.right.end() );
            int pter = rhs.left.size() - 1;
            for (int i = 0; i < right.size(); ++i) {
                while(pter >= 0 && right[i] + rhs.left[pter] >= 0) pter --;
                ret.ans += rhs.left.size() - pter - 1;
            }
            return ret;
        }
    } node[N << 2];
    void build_tree(int nd, int left, int right) {
        if(left == right) { node[nd] = Node(a[left]); return ; }
        int mid = left + right >> 1;
        build_tree(nd << 1, left, mid); build_tree(nd << 1 | 1, mid + 1, right);
        node[nd] = node[nd << 1] + node[nd << 1 | 1];
    }
} it;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> K;
    for (int i = 1; i <= n; ++i) cin >> a[i], a[i] -= K;

    it.build_tree(1, 1, n);

    cout << it.node[1].ans;

    return 0;
}


Measured memory_bytes: 138736
def gcd(x, y):
  while y!=0:
    x,y=y,x%y
  return x

a, b, c, d=map(int, input().split())
lcm=c*d//(gcd(c,d))
print(b-a+1-((b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//lcm-(a-1)//lcm)))

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1<<30)
input = sys.stdin.readline
N, M = map(int, input().split())

e = [-1] * N

def find(x):
	if e[x] < 0: return x
	e[x] = find(e[x])
	return e[x]

def join(a, b):
	a, b = find(a), find(b)
	if a == b: return
	if e[a] > e[b]: a, b = b, a
	e[a] += e[b]
	e[b] = a

for _ in range(M):
	x, y = map(int, input().split())
	join(x-1, y-1)

print(-min(e))


Measured memory_bytes: 73716
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < n; ++i)
#define X first
#define Y second
#define all(x) x.begin(), x.end()
using namespace std;
using PII=pair<int,int>;

vector<PII> g[200000];

// Tree
class Node{
  public:
    int value;
    int parent;
    Node(){value=0;};
    Node(int d){value=d;};
};

Node nodes[200000];
int a, b, c, n;
int ans;

PII dfs(int from, int to){
  PII mx(0,to);
//   cout << "index: " << to<< endl;

  rep(i, g[to].size()){
    if(from == g[to][i].X)continue;
    PII val = PII(dfs(to, g[to][i].X));
    val.X += g[to][i].Y;
    if(mx.X <  val.X){
      mx = val;
    }
  }

//   cout << "mx.X " << mx.X << " " << mx.Y << endl;
//   cout << endl;
  return mx;
}


int main(void){

  cin >> n;

  rep(i,n-1){
    cin >> a >> b >> c;
    if(a>b) swap(a,b);
    g[a].push_back(PII(b,c));
    g[b].push_back(PII(a,c));

    nodes[b].parent = a;
    nodes[b].value = c;
  }

  PII r = dfs(-1, 0);
//   cout << r.X << " " << r.Y << endl;
//   cout << endl;
  PII t = dfs(-1, r.Y);
//   cout << t.X << " " << t.Y << endl;
  cout << t.X << endl;
  

  return 0;
}

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

#define MAX_N 20
#define MAX_M 6000000
#define MAX_P 300000

int d[MAX_N][MAX_N];
int dp[MAX_M];
int dp2[MAX_M];
int DP[MAX_N];
int main(){
	int n,m,p;
	cin>>m>>n>>p;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>d[i][j];
		}
	}
	for(int i=0;i<MAX_N;i++){
		DP[i]=0;
	}
	DP[0]=p;
	for(int i=0;i<n-1;i++){
		for(int j=0;j<MAX_M;j++){
			dp[j]=0;dp2[j]=0;
		}
		for(int j=0;j<m;j++){
			for(int k=0;k<MAX_M-MAX_P;k++){
				dp[k+d[i][j]]=max(dp[k+d[i][j]],dp[k]+d[i+1][j]);
			}
		}
		for(int j=1;j<MAX_M;j++){
			dp2[j]=max(dp2[j],max(dp[j]-j,dp2[j-1]));
		}
		DP[i+1]=DP[i]+dp2[DP[i]];
	}
	cout<<DP[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 48036
program main
  implicit none
  
  integer :: n,a(200)=0,i,c=0
  read(*,*)n
  read(*,*)(a(i), i =1, n)
  
  do
    do i = 1, n
      if (mod(a(i),2) == 1) then
        write(*,*)c
        stop
      else
        a(i) = a(i)/2
      end if
    end do
    c = c + 1
  end do
end program main

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
            
        Scanner sc =new Scanner(System.in);
    
        int n = sc.nextInt();
        double sum = 0;
        int[] lst = new int[n];
    
        for(int i=0;i<n;i++){
            lst[i] = sc.nextInt();
            sum+=lst[i];
        }
        
        int ans = 0;double min = 0;
        sum /= n;
        for(int i=0;i<n;i++){
            if(i==0){min=Math.abs(lst[i]-sum);continue;}
            if(min>Math.abs(lst[i]-sum)){
                min=Math.abs(lst[i]-sum);
                ans=i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll h, w;
    cin >> h >> w;

    vvl board(h, vl(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board[i][j] = 1;
            }
        }
    }

    vvl dp(h, vl(w, -1));  /// dp[i][j] : (i,j)に到達するための操作回数の最小値
    if(board[0][0]) {
        dp[0][0] = 1;
    }
    else {
        dp[0][0] = 0;
    }
    exrep(j, 1, w-1) {
        dp[0][j] = dp[0][j-1];
        if(board[0][j-1] == 0 && board[0][j] == 1) {
            dp[0][j]++;
        }
    }
    exrep(i, 1, h-1) {
        dp[i][0] = dp[i-1][0];
        if(board[i-1][0] == 0 && board[i][0] == 1) {
            dp[i][0]++;
        }
    }

    exrep(i, 1, h-1) {
        exrep(j, 1, w-1) {
            ll x = dp[i-1][j];
            ll y = dp[i][j-1];
            if(board[i][j]) {
                if(board[i-1][j] == 0) {
                    x++;
                }
                if(board[i][j-1] == 0) {
                    y++;
                }
            }
            dp[i][j] = min(x, y);
        }
    }

    out(dp[h-1][w-1]);
    re0;
}

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

int main() { 
  int N, A, B;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
    cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int i = 0; i < vec.size(); i++){
    if (i % 2 == 0)
      A = A + vec.at(i);
    else
      B = B + vec.at(i);
  }
  cout << A - B << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
string s;
bool dfs(int now) {
  if (now == s.size()) return true;
  bool ok = false;
  if (s[now] == 'd') {
    if (s.substr(now, 5) == "dream") ok |= dfs(now+5);
    if (s.substr(now, 7) == "dreamer") ok |= dfs(now+7);
  } else if (s[now] == 'e') {
    if (s.substr(now, 5) == "erase") ok |= dfs(now+5);
    if (s.substr(now, 6) == "eraser") ok |= dfs(now+6);
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  cin >> s;
  cout << (dfs(0) ? "YES" : "NO") << '\n';
  return 0;
}


Measured memory_bytes: 2128
/*
      author  : nishi5451
      created : 15.08.2020 13:52:06
*/

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


int main(){
    int n,h;
    cin >> h >> n;
    int sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
ll h[200200];

int main()
{
  ll n,k;cin>>n>>k;
  for(ll i=0;i<n;i++){
    cin>>h[i];
  }
  if(k>=n){
    cout<<0<<endl;return 0;
  }
  ll sum=0;
  sort(h,h+n);
  for(ll i=0;i<n-k;i++)sum+=h[i];
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

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

    if(a==b && b!=c) flag=1;
    if(b==c && c!=a) flag=1;
    if(c==a && a!=b) flag=1;

    if(flag==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
  int height[10];
  int counter;  int max=-1;
  int i;        int tmp;
   for(counter=0;counter<10;counter++)
    scanf("%d",(height+counter));

   for(i=0;i<3;i++){
    for(counter=0;counter<10;counter++){
      if(height[counter]>max){
         max=height[counter];
         tmp=counter;
        }
      }
    height[tmp]=-1;
    printf("%d\n",max);
    max=-1;
     }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> tree(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].emplace_back(b, i);
    tree[b].emplace_back(a, i);
  }
  int K = 0;
  for (int i = 0; i < N; i++) K = max(K, (int)tree[i].size());
  int c[N - 1];
  fill(c, c + N - 1, -1);
  function<void(int, int, int)> dfs = [&](int v, int p, int color) {
    int cnum = 1;
    for (auto e : tree[v])
      if (e.first != p) {
        if (cnum == color) cnum++;
        c[e.second] = cnum;
        dfs(e.first, v, cnum);
        cnum++;
      }
  };
  dfs(0, -1, -1);
  cout << K << '\n';
  for (int i = 0; i < N - 1; i++) cout << c[i] << '\n';
  return 0;
}


Measured memory_bytes: 12948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=1; i<n; i++)
typedef int64_t lint;
const int mod = 1000000007;
struct mint {
	lint x;
	mint(lint x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(lint t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	int N;
	cin >> N;
	vector<vector<mint>> v(N, vector<mint>(4));
	if (N == 1) std::cout << "0" << '\n';
	else if (N == 2) std::cout << "2" << '\n';
	else {
		v[0][0] = 0;
		v[0][1] = 1;
		v[0][2] = 1;
		v[0][3] = 8;
		rep(i, N) {
			v[i][3] = v[i-1][3]*8;
			v[i][2] = v[i-1][3] + v[i-1][2]*9;
			v[i][1] = v[i-1][3] + v[i-1][1]*9;
			v[i][0] = v[i-1][2] + v[i-1][1] + v[i-1][0]*10;
		}
		std::cout << v[N-1][0] << '\n';
	}
}


Measured memory_bytes: 73284
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    vector<int> left(N), right(N);
    left[0] = a[0], right[N-1] = a[N-1];
    for(int i=1;i<N;i++) left[i] = left[i-1] ^ a[i];
    for(int i=N-2;i>=0;i--) right[i] = right[i+1] ^ a[i];
    REP(i,N){
        if(i == 0) cout << right[i+1] << " ";
        else if(i == N-1) cout << left[i-1] << " ";
        else cout << (left[i-1] ^ right[i+1]) << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

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

using namespace std;


int main(void) {

	int R, G, B, K;
	cin >> R >> G >> B;
	cin >> K;

	int count = 0;

	while (G <= R) {
		if (count >= K) {
			cout << "No" << endl;
			return 0;
		}
		G *= 2;
		count++;
	}

	while (B <= G) {
		if (count >= K) {
			cout << "No" << endl;
			return 0;
		}
		B *= 2;
		count++;
	}

	cout << "Yes" << endl;


	return 0;
}

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

int main() {
  string s;
  cin>>s;
  int cnt = 0;
  for (int i=0; i<3; i++) {
    if (s[i] == 'o') {
      ++cnt;
    }
  }
  cout<<700 + cnt * 100<<endl;
}

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

int main(){
	int x; cin>>x;
	int ans=0;
	for(int i=1; i<=x; i++){
		ans+=i;
		if(ans>=x) {cout<<i<<endl; return 0;}
	}
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int visited[200001];

int dfs(int node, int p, vector<int> v[], int  ans){
    visited[node] = 1;
    for(auto to: v[node]){
        if(to == p){
            continue; 
        }
        if(!visited[to]){
            ans  = dfs(to, node, v, ans + 1);
        }
    }
    return ans;
}

int run_test(){
    int n, m;
    cin >> n>> m;
    vector<int> v[n];
    set<pii> s;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(s.count({a, b}) == 0 && s.count({b,a}) == 0){
            s.insert({a, b});
            v[a].pb(b);
            v[b].pb(a);
        }
    }
    fill(visited, 0);
    int ans =1; 
    for(int i=0; i<n; i++){
        if(!visited[i]){
            ans = max(ans, dfs(i, i, v, 1));
        }
    }
    cout << ans;
    return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 37232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  string S,T;
  cin >> S >> T;
  
  bool can = true;
  map<char,char> abc;
  map<char,char> def;
  for (int i = 0; i < S.size(); i++) {
    if (!abc.count(T.at(i))) abc[T.at(i)] = S.at(i);
    else if (abc.at(T.at(i)) != S.at(i)) can = false;
    
    if (!def.count(S.at(i))) def[S.at(i)] = T.at(i);
    else if (def.at(S.at(i)) != T.at(i)) can = false;
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 776
N, M = map(int,input().split())

mae = set()
ato = set()
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        mae.add(b)
    if b == N:
        ato.add(a)

if len(mae&ato) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 18936
#include <stdio.h>
#include <iostream>

using namespace std;

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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  rep(i, n) {
    ll res;
    if (i < m) res = l;
    else {
      if (l < 100) res = l+1;
      else res = l-1;
    }
    if (i) cout << ' ' << res;
    else cout << res;
  }
  cout << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

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

    VVL a(n, VL(n));
    rep(i,n) rep(j,n) cin >> a[i][j];

    rep(k,n) rep(i,n) rep(j,n){
        if (chmin(a[i][j], a[i][k] + a[j][k])){
            cout << -1 << endl;
            return 0;
        }
    }

    vector<vector<bool>>  isEdge(n, vector<bool>(n, true));
    rep(w,n) rep(u,n) rep(v,n) {
        if (u == v) isEdge[u][v] = false;
        else if (u != w && v != w && a[u][v] == a[u][w] + a[w][v]) isEdge[u][v] = false;
    }

    ll sum = 0;
    rep(i,n) rep(j,n) if (isEdge[i][j]) sum += a[i][j];
    sum /= 2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

typedef long long ll;

#define pb push_back

int cnt_bit(int n){
	int ret = 0;
	while(n > 0){
		ret ++;
		n -= n&-n;
	}
	return ret;
}

int main(){
	while(1){
		static int n,c,in;
		static int a[32],b[32];
		static int dp[32][1<<16];
		scanf("%d%d",&n,&c); if(n == 0)break;
		for(int i = 0 ; i < n ; i ++){
			a[i] = 0;
			for(int j = 0 ; j < 16 ; j ++){
				scanf("%d",&in);
				a[i] <<= 1;
				a[i] |= in;
			}
		}
		for(int i = 0 ; i < c ; i++){
			b[i] = 0;
			for(int j = 0 ; j < 16 ; j ++){
				scanf("%d",&in);
				b[i] <<= 1;
				b[i] |= in;
			}
		}
		int t = 0 , t_ = 1;
		for(int i = 0 ; i < 2 ; i ++){
			for(int j = 0 ; j < (1<<16) ; j ++){
				dp[i][j] = -1000000;
			}
		}
		dp[t][0] = 0;
		for(int i = 0 ; i < n ; i ++){
			for(int j = 0 ; j < (1<<16) ; j ++){
				if(dp[t][j] < 0)continue;
				for(int k = 0 ; k < c ; k ++){
					int sc = cnt_bit((j|a[i])&b[k]);
					int nex = (j|a[i])-((j|a[i])&b[k]);
					dp[t_][nex] = max ( dp[t_][nex] , dp[t][j] + sc );
				}
			}
			swap(t,t_);
		}
		int ret = 0;
		for(int i = 0 ; i < (1<<16) ; i ++){
			ret = max ( ret , dp[t][i] );
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1704
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int N, C; cin >> N >> C;
    vector<vector<int>> sum(200010, vector<int>(35));

    rep(i,N) {
        int s, t, c; cin >> s >> t >> c;
        c--;
        sum[s*2-1][c]++;
        sum[t*2+1][c]--;
    }

    // rep(i,C) {
    //     rep(j,30) cout << sum[j][i] << " ";
    //     cout << endl;
    // }

    int ans = 0, tmp;
    vector<int> state(C);
    rep(i,200000+1) {
        rep(j,C) {
            state[j] += sum[i][j];
        }
        tmp = 0;
        rep(j,C) {
            if (state[j]) tmp++;
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 36224
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	IOS;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = (a-1)/d + 1;
	int y = (c-1)/b + 1;
	if(x >= y)
		cout << "Yes";
	else
		cout << "No";	
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
ll arr[405];
ll parr[405];
ll dp[405][405];
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	for(ll i=1;i<=n;i++)
		parr[i]=parr[i-1]+arr[i];
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<=n-i;j++)
		{
			ll m=inf;
			for(ll k=j;k<j+i;k++)
			{
				m=min(m,dp[j][k]+dp[k+1][j+i]+parr[j+i]-parr[j-1]);
			}
			dp[j][j+i]=m;
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}

Measured memory_bytes: 1536
from math import cos, sin, pi, sqrt
a,b,h,m = map(int, input().split())
# 座標
theta1 = 360/12 * (h+m/60)
theta1 = theta1*2*pi/360
theta2 = 360/60 * m
theta2 = theta2*2*pi/360

x1, y1 = -sin(-theta1)*a, cos(-theta1)*a
x2, y2 = -sin(-theta2)*b, cos(-theta2)*b
x = x1-x2
y = y1-y2
ans = sqrt(x*x + y*y)
print(ans)

Measured memory_bytes: 9588
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1e9+7;

int dp[1001][1001];
char grid[1001][1001];

int main() {
    int r, c;
    scanf("%d%d", &r, &c);
    int up, left;


    for (int i=0; i < r; i++)
        scanf("%s", &grid[i]);
    dp[0][0] = 1;
    for (int i=0; i < r; i++) {
        for (int j=0; j < c; j++) {
            up = 0; left = 0;
            // calculate up paths
            if (i-1 >= 0 && grid[i][j] == '.')
                up = dp[i-1][j];
            else
                up = 0;
            if (j-1 >= 0 && grid[i][j] == '.')
                left = dp[i][j-1];
            else
                left = 0;
            if (i != 0 || j != 0)
                dp[i][j] = (up+left) % MOD;
        }
    }
    cout << dp[r-1][c-1] << endl;
}


Measured memory_bytes: 8548
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    ll N; cin >> N;
    vector<ll> H(N,0); for(int i = 0; i < N; i++) cin >> H[i];
    
    ll count = 0;
    ll ans = 0;
    for(int i = 0; i < N-1; i++){
        // cout << i << " " << H[i] << " " << H[i+1] << "\n";
        if(H[i] >= H[i+1]) count++;
        else{
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int x,a,b;
	int ans=0;
	
	cin>>x>>a>>b;
	if(abs(a-x)>abs(b-x))
		cout<<"B"<<endl;
	else
		cout<<"A"<<endl;
	return 0;
}

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

int main()
{
	int X;

	cin >> X;

	if(X==7){
		cout << "YES" << endl;
	}

 else if (X == 5){
 cout << "YES" << endl;
	}

 else if (X == 3) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
        int N,M; cin >> N >> M;
        if (N+M==0) break;
        vector<int> A(N);
        rep(i,N) cin >> A[i];

        int ans = 0;
        rep(i,N) {
            for (int j = i+1; j < N; j++) {
                if (A[i] + A[j] <= M) chmax(ans,A[i]+A[j]);
            }
        }

        if (ans > 0) cout << ans << endl;
        else cout << "NONE" << endl;
    }
}


Measured memory_bytes: 3148
#include <stdio.h>
#define A 20
#define M 200

int n,a[A],f=0;
 

int cal(int i, int m)
{
 
  if(m == 0){
    f = 1;
   return 1;
  }
   
   else if(i < n){
    cal(i+1, m);
    cal(i+1, m - a[i]);
  
     }
}

int main()
{
 
  int i,j;
  int b[M];
  int q;
   
  scanf("%d",&n);
   
  for(i = 0; i < n; i++){
    
     scanf("%d",&a[i]);
  }
 
  scanf("%d",&q);
   
  for(j = 0; j < q; j++){
    
     scanf("%d",&b[j]);
  }
   
   
  for(i = 0; i < q; i++){
    f = 0;
    cal(0,b[i]);
    
    if(f == 1) printf("yes\n");
    
    else  printf("no\n");
    
  }
 
  return 0;
}
 
 

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m; int cnt[100005];
int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;cin>>a>>b;cnt[a]++;cnt[b]++;
	}
	repn(i,n) if(cnt[i]%2==1){ puts("NO"); return 0;}
	puts("YES");
}

Measured memory_bytes: 640
/*input
hello
*/

#include <iostream>
#include <cstring>
#include <stdio.h>

using namespace std;

int main(){
	string s;
	cin>>s;
	int l = s.size(), i, j;
	for(i = 0; i<l; i++){
		if(s[i] == 'A')
			break;
	}
	for(j = l-1; j>=0; j--){
		if(s[j] == 'Z')
			break;
	}
	cout<<j-i+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

const int MAX = 25 + 5;
const int NIL = -1;

struct Node {
	int parent = NIL;
	int left = NIL;
	int right = NIL;
};

Node T[MAX];

void preorder(int c) {
	std::cout << " " << c;
	if (T[c].left != NIL) preorder(T[c].left);
	if (T[c].right != NIL) preorder(T[c].right);
}

void inorder(int c) {
	if (T[c].left != NIL) inorder(T[c].left);
	std::cout << " " << c;
	if (T[c].right != NIL) inorder(T[c].right);
}

void postorder(int c) {
	if (T[c].left != NIL) postorder(T[c].left);
	if (T[c].right != NIL) postorder(T[c].right);
	std::cout << " " << c;
}

int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i != n; ++i) {
		int id, l, r;
		std::cin >> id >> l >> r;
		T[id].left = l;
		T[id].right = r;
		if (l != NIL) {
			T[l].parent = id;
		}
		if (r != NIL) {
			T[r].parent = id;
		}
	}

	int r = 0;
	for (int i = 0; i != n; ++i) {
		if (T[i].parent == NIL) r = i;
	}

	std::cout << "Preorder" << std::endl;
	preorder(r);
	std::cout << std::endl;
	std::cout << "Inorder" << std::endl;
	inorder(r);
	std::cout << std::endl;
	std::cout << "Postorder" << std::endl;
	postorder(r);
	std::cout << std::endl;

	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<iomanip>
using namespace std;
/*int main() 
{
	int x, y;
	double f;
	cin >> x >> y;
	f = 1.0*x / y;
	cout << x/y << " " << x%y << " " << fixed << setprecision(6) <<  f << endl;
}*/

int main()
{
	double r;
	double a, b;
	cin >> r;
	a = r * r * 3.141592653589;
	b = r * 2 * 3.141592653589;
	
	cout << fixed << setprecision(6) << a << " " << fixed << setprecision(6) << b << endl;
}




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

int main(void) {
    
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    rep(i,n){
        if(a[i]%2==1){
            continue;
        }else{
            if(a[i]%3==0){
                continue;
            }else if(a[i]%5==0){
                continue;
            }else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;


    return 0;
    
}

Measured memory_bytes: 256
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    FAST;
    ll a,b,k;
    cin>>a>>b>>k;
    ll mn=min(b,(a+k-1));
    ll mx=max(a+k,(b-k+1));
    for(ll i=a;i<=mn;i++)
    {
        cout<<i<<endl;
    }
    for(ll i=mx;i<=b;i++)
    {
        cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int data_num = 10;
		int top = 3;
		int[] data = new int[data_num];

		for(int i = 0; i < data_num; i++){
			data[i] = Integer.parseInt(br.readLine());
		}

		for(int i = 0; i < data_num; i++){
			for(int j = data_num - 1; j > i; j--){
				if(data[j - 1] < data[j]){
					int temp = data[j - 1];
					data[j - 1] = data[j];
					data[j] = temp;
				}
			}
		}

		for(int i = 0; i < top; i++){
			System.out.println(data[i]);
		}


	}
}

Measured memory_bytes: 24084
using System;
using System.Collections.Generic;
using System.Linq;


namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var length = int.Parse(Console.ReadLine());
            var count = 0;
            for (int i = 0; i < length; i++)
            {
                var str = Console.ReadLine()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(x => int.Parse(x))
                    .ToArray();
                count += (str[1] - str[0] + 1);
            }
            Console.WriteLine(count);

        }
    }

}

Measured memory_bytes: 13396
program main
character S*103
integer K,K2,I

read *,K
read *,S
I = K + 1
K2 = len_trim(S)
if( K < K2 ) then
  S(I:K2) = ""
  S(I:I) = "."
  S(I+1:I+1) = "."
  S(I+2:I+2) = "."
end if
print '(A)', trim(S)
end program main

Measured memory_bytes: 2928