akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL H, A;
	cin >> H >> A;

	LL ans = ceil((double)H / A);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
        double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
}
template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
         return false;
}
using namespace std;


int dp[2009];
int mod = 1e9 + 7;

int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        // cout << fixed << setprecision(15);
        int s;
        cin >> s;

        rep(i, s) dp[i] = 0;
        dp[0] = 1;
        int x = 0;
        repi(i, 1, s+1) {
            // rep(k, i - 2){
            //     dp[i] += dp[k];
            //     dp[i] %= mod;
            // }
            if (i - 3 >= 0) {
                x += dp[i- 3];
                x %= mod;
            }
            dp[i] = x;
        }
        cout << dp[s] << endl;

        return 0;
}

Measured memory_bytes: 3604
N = int(input())
def dfs(x):
  ret = 0
  if int(x)>N:
    return 0
  if all(x.count(i)>0 for i in "753"):
    ret += 1
  for i in "753":
    ret += dfs(x+i)
  return ret
print(dfs("0"))

Measured memory_bytes: 9052
#pragma GCC target("arch=skylake-avx512")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>

int32_t n;
int32_t a[200000];
int32_t b[200000];

int main(void) {
    scanf("%" SCNd32, &n);
    for (int32_t i = 0; i < n; ++i) {
        scanf("%" SCNd32, &a[i]);
        b[i] = a[i] + n - i - 1;
    }
    int64_t cnt = 0;
    for (int32_t i = 0; i < n; ++i) {
        int32_t c = n - i - 1 - a[i];
        for (int32_t j = i + 1; j < n; ++j) {
            if (b[j] == c) {
                ++cnt;
            }
        }
    }
    printf("%" PRId64 "\n", cnt);
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  vector<ll> a(n);
  vector<ll> b(m);
  for (long long i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (long long i = 0; i < m; i++) {
    cin >> b.at(i);
  }

  ll a_max = 0;
  ll b_max = 0;
  ll cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (k >= a.at(i)) {
      k -= a.at(i);
      a_max++;
      cnt++;
    } else {
      break;
    }
  }
  for (long long i = 0; i < m; i++) {
    if (k >= b.at(i)) {
      k -= b.at(i);
      b_max++;
      cnt++;
    } else {
      break;
    }
  }
  ll ans = cnt;
  for (long long i = a_max - 1; i >= 0; i--) {
    k += a.at(i);
    cnt--;
    for (long long j = b_max; j < m; j++) {
      if (k >= b.at(j)) {
        k -= b.at(j);
        b_max++;
        cnt++;
      } else {
        break;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[2][100010];

void solve() {
    ll N, W;
    cin >> N >> W;
    Vl ws(N), vs(N);
    for (ll i = 0; i < N; i++) {
        cin >> ws[i] >> vs[i];
    }

    auto dp1 = dp[0];
    auto dp2 = dp[1];
    for (ll i = 0; i < N; i++) {
        swap(dp1, dp2);
        memset(dp2, 0, sizeof(ll) * W);
        for (ll j = 0; j <= W; j++) {
            dp2[j] = dp1[j];
            if (j - ws[i] >= 0)
                chmax(dp2[j], dp1[j - ws[i]] + vs[i]);
        }
    }

    prints()(dp2[W]);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vectors<decltype(inner)>(x, inner); }
template<class T> void show_with_brank(T a){ int cnt = 0; for(auto itr :a){ if(cnt++ != 0) cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
class unionfind {
    vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う
public:
    unionfind(int n) :par(n), rank(n), size_(n, 1) {
        iota(all(par), 0);
    }
    int find(int x) {
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])swap(x, y);
        par[y] = x;
        size_[x] += size_[y];
        if (rank[x] == rank[y])rank[x]++;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return size_[find(x)];
    }
};
signed main(){
    int n,m; cin >> n >> m;
    vector<int>p(n);
    rep(i,n) cin >> p[i];
    unionfind uni(1e5 + 1);
    rep(i,m){
        int a,b; cin >> a >> b;
        uni.unite(a, b);
    }
    int ans = 0;
    rep(i,n){
        if(uni.same(p[i], i+1))ans++;
    }
    cout << ans << endl;
}





Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
int N,M;
cin>>N>>M;
int P[50]={},Q[50]={};
for(int i=0;i<M;i++){
    cin>>P[i]>>Q[i];
}
int answer[50]={0};
for(int i=0;i<M;i++){
    answer[P[i]-1]+=1;
    answer[Q[i]-1]+=1;
}
for(int i=0;i<N;i++){
    cout<<answer[i]<<endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
#define pcii pair<char, pair<int, int>>
using namespace std;

const ll N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 5;

void solve(){
    int n, m;
    cin >> n >> m;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    vector<vl> dp(n + 1, vl(m + 1, -1));
    for(int i = 0; i <= n; i++) dp[i][0] = 0;
    for(int i = 0; i <= m; i++) dp[0][i] = 0;
    dp[1][1] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i - 1][j - 1] == '#'){
                dp[i][j] = 0;
                continue;
            }
            if(i == 1 && j == 1) continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m] << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12160
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]

c = [[0] * l for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
    print(*c[i])



Measured memory_bytes: 7028
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;
 
 
 
int main(){
	int N;
	cin >> N;
	string a;
	//  c1 => ( 
	//  c2 => )
	int c=0,c1=0,c2=0;
	cin >> a;
	for(int i=0;i<N;i++){
		if(c==0 && a[i]==')')
			c1++;
		else if(a[i]==')')
			c--;
		if(a[i]=='(')
			c++;
	}
	for(int i=0;i<c1;i++)
		cout << '(';
	cout << a;
	for(int i=0;i<c;i++)
		cout << ')';


	
	cin >> N;
	return 0;
 
 
 
}

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

int main() {
while(true){
int x, y, z;
cin  >> x >> y >> z;
if(x == -1 && y == -1 && z == -1){
break;
}

if(x == -1 || y == -1){
cout << "F" << endl;
}
else if(x+y >= 80){
cout << "A" << endl;
}
else if(x+y >= 65){
cout << "B" << endl;
}
else if(x+y >= 50){
cout << "C" << endl;
}
else if(x+y >= 30 && z >= 50){
cout << "C" << endl;
}
else if(x+y >= 30){
cout << "D" << endl;
}

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

}



}



Measured memory_bytes: 3076
#include<cstdio>
const int N=100+10;
int n;
char a[N],b[N];
int main()
{
	scanf("%d%s%s",&n,a+1,b+1);
	for(int i=1;i<=n;i++)
		printf("%c%c",a[i],b[i]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

bool isPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
      return false;
    }
  }
  return true;
}

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

  char c;
  cin >> c;
  if(c == 'A') cout << 'T' << endl;
  if(c == 'T') cout << 'A' << endl;
  if(c == 'C') cout << 'G' << endl;
  if(c == 'G') cout << 'C' << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        int N = sc.nextInt();
        String result = "YES";
        Set<String> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            String A = sc.next();
            if (set.contains(A)) {
                result = "NO";
                break;
            }
            set.add(A);
        }

        System.out.println(result);

        sc.close();
    }

}


Measured memory_bytes: 76068
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll N, K;
    cin >> N >> K;
    if(K == 0){
        PRINT(N * N);
        return 0;
    }
    ll ans = 0;
    FOR(b, K + 1, N + 1){
        ans += (b - K) * (N / b);
        ans += max(0LL, N % b - K + 1);
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ka = []
for i in range(n):
    ka.append(list(map(int, input().split())))
ok = 0
flag = False
for j in range(1, 31):
    for i in range(n):
        row = ka[i][1:]
        flag = (j in row)
        if not flag:
            break
    if flag:
        ok += 1
        flag = False
print(ok)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++)cin>>h[i];
  int ans=h[0];
  for(int i=1;i<n;i++){
    if(h[i-1]>=h[i])continue;
    ans+=h[i]-h[i-1];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int H,W,h,w;
int main(){
    cin>>H>>W>>h>>w;
    if((H%h==0)&&(W%w==0)){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        REP(i,H){
            REP(j,W){
                if(i%h==0&&j%w==0){
                   cout<<1000000-1;
                }else if(i%h==h-1&&j%w==w-1){
                   cout<<-1000000;
                }else{
                   cout<<0;
                }
                if(j!=W-1){
                   cout<<" ";
                }else{
                   cout<<endl;
                }
            }
        }
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V h(n);rep(i,n)cin>>h[i];
    int ans=1;
    int M=h[0];
    for(int i=1;i<n;i++){
        if(M<=h[i]){
            ans++;
            M=h[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	printf("%d\n", ((A < B)? A: B) + ((C < D)? C: D));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define f first
#define s second

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    CIN(N);CIN(M);
    vector<int> vec(N,1),flag(N,0);
    flag.at(0)=1;
    REP(a,M){
        CIN(x);CIN(y);
        if(flag.at(x-1)){
            flag.at(y-1)=1;
        }
        vec.at(x-1)--;
        vec.at(y-1)++;
        if(vec.at(x-1)==0)flag.at(x-1)=0;
    }
    COUT(count(ALL(flag),1));
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int s = NextInt, w = NextInt;
            if (w >= s)
            {
                System.Console.WriteLine("unsafe");
            }
            else
            {
                System.Console.WriteLine("safe");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27660
def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p, r):
        if a[j] <= x:
            i = i + 1
            a[i], a[j] = a[j], a[i]
    a[i + 1], a[r] = a[r], a[i + 1]
    return(i + 1)
 
n = int(input())
l = list(map(int, input().split()))
i = partition(l, 0, n - 1)
l[i] = "[%d]"%l[i]
print(*l)


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

int abs (int x, int y) {
  if (x > y) {
    return x - y;  
  }  
  return y - x;
}

int main () {
  int n;
  cin >> n;
  int A[n + 1];
  long long sum[n + 1];
  A[0] = 0;
  sum[0] = 0;
  
  for (int i = 0; i < n; i++) {
    cin >> A[i + 1];  
    if (i == 0) {
      if (A[i + 1] > 0) {
        sum[i + 1] = A[i + 1]; 
      }
      else {
        sum[i + 1] = -1 * A[i + 1];  
      }
    }
    else {
      sum[i + 1] = sum[i] + abs(A[i], A[i + 1]);  
    }
  }  
  sum[n] = sum[n] + abs(A[0], A[n]);
  for (int i = 0; i < n; i++) {
    int sub = sum[n];
    if ( i == n - 1) {
      cout << sum[n - 1] + abs(A[0], A[n - 1]) << endl;
      break;  
    }
    sub = sub - abs(A[i + 1], A[i]) - abs(A[i + 1], A[i + 2]) + abs(A[i], A[i + 2]);
    cout << sub << endl;
  }
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).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 each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

const double EPS=1e-7;
int N;
int par[100];
double x[100],y[100],z[100],r[100];
void init(){
    rep(i,N)par[i]=i;
}
int find(int x){
    return x==par[x]?x:par[x]=find(par[x]);
}
void unite(int x,int y){
    par[find(y)]=find(x);
}
bool same(int x,int y){
    return find(x)==find(y);
}


signed main(){
    while(cin>>N,N){
        rep(i,N)cin>>x[i]>>y[i]>>z[i]>>r[i];
        init();
        vector<tuple<double,int,int>>vec;
        rep(i,N)rep(j,N){
            double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
            if(r[i]+r[j]+EPS>d)unite(i,j);
            else vec.pb(make_tuple(d-r[i]-r[j],i,j));
        }
        sort(all(vec));
        double ans=0;
        rep(i,vec.size()){
            double d;
            int u,v;
            tie(d,u,v)=vec[i];
            if(same(u,v))continue;
            ans+=d;
            unite(u,v);
        }
        printf("%.3f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3444
mod = 10**9+7
fact=[0 for i in range(0, 200000)]
def precompute():
	fact[0]=1
	for i in range(1, 30000):
		fact[i]=(fact[i-1]*i)%mod
def mexp(a, b):
	res = 1
	while b:
		if b%2!=0:
			res =(res%mod)*(a%mod)
			res = res%mod
		a = (a%mod)*(a%mod)
		a = a%mod
		b=b//2
	return res%mod

def ncr(n , r):
	p = fact[n]
	p = p*(mexp(fact[n-r] , mod-2))
	p=p%mod
	p = p*(mexp(fact[r] , mod-2))
	p=p%mod
	return p

def main():
	precompute()
	n , k = map(int, input().split())
	for i in range(1, k+1):
		now = (ncr(n+1-k, i)%mod)*(ncr(k-1, i-1)%mod)
		now = now%mod
		print(now)

if __name__ =="__main__":
	main()

Measured memory_bytes: 86620
package main

import (
  "fmt"
)

func main() {
  var n int
  var array []int
  cnt := 0
  flg := true
  
  fmt.Scan(&n)
  array = make([]int, n)

  for i:= 0;i < n; i++ {
    fmt.Scan(&array[i])
  }
  
  for {
    for i := 0;i < n; i++ {
      if array[i] % 2 == 1 {
        flg = false
      	break
      }
    }
    if flg == true {
      cnt++
      for j := 0;j < n; j++ {
        array[j] /= 2
      }
    } else {
      fmt.Println(cnt)
      break
    }
  }
}


Measured memory_bytes: 512
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

def int_input():
    return int(input())


def print_ans(string):
    print(string)
    exit()

def yes():
    print("Yes")
    exit()

def no():
    print("No")
    exit()

A,B,C,K=input_int_list()

if K<=A:
    print_ans(K)
else:
    if K<=A+B:
        print_ans(A)
    else:
        print_ans(2*A-K+B)


Measured memory_bytes: 9036
n = gets.chomp
s = n.size

ans = true
for i in 0..(s-3)/2
  ans = false if n[i] != n[-i-2]
end
ans = false if n[-1] == "1" || n[0] == "0"

if ans
  l = 1
  for i in 2..s
    if n[i-2] == "0"
      puts "#{l} #{i}"
    else
      puts "#{l} #{i}"
      l = i
    end
  end
else
  puts -1
end

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a + b < 10)print(a+b);
    else print("error");
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,v=1<<16;
  cin>>n;
  int h[n],w[n],dp[v],used[v];
  for(int i=0;i<n;i++) cin>>h[i]>>w[i];
  string s[4],c="RGB";;
  for(int i=0;i<4;i++) cin>>s[i];
  memset(dp,-1,sizeof(dp));
  memset(used,0,sizeof(used));
  queue<P> q;
  q.push(P(0,0));
  while(!q.empty()){
    int bit=q.front().first,d=q.front().second;
    q.pop();
    if(~dp[bit]) continue;
    dp[bit]=d;
    for(int i=0;i<n;i++)
      for(int j=-h[i]+1;j<4;j++)
	for(int k=-w[i]+1;k<4;k++)
	  for(int l=0;l<3;l++){
	    int z=bit;
	    for(int a=max(0,-j);a<min(h[i],4-j);a++){
	      for(int b=max(0,-k);b<min(w[i],4-k);b++){
		int y=j+a,x=k+b;
		if(s[y][x]==c[l]) z|=1<<(y*4+x);
		else z&=v-1-(1<<(y*4+x));
	      }
	    }
	    if(dp[z]<0&&!used[z]) q.push(P(z,d+1)),used[z]=1;
	  }
  }
  cout<<dp[v-1]<<endl;
  return 0;
}

Measured memory_bytes: 3836
#include<stdio.h>
#define MAX 200000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];

long long merge(int A[],int n,int left,int mid,int right){
	int i,j,k;
	long cnt=0;
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=SENTINEL;
	R[n2]=SENTINEL;
	i=0,j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}
		else{
			A[k]=R[j++];
			cnt+=n1-i;
		}
	}
	return cnt;
}

long long mergeSort(int A[],int n,int left,int right){
	int mid;
	long long v1,v2,v3;
	if(left+1<right){
		mid=(left+right)/2;
		v1=mergeSort(A,n,left,mid);
		v2=mergeSort(A,n,mid,right);
		v3=merge(A,n,left,mid,right);
		return v1+v2+v3;
	}
	else{
		return 0;
	}
}

int main(void){
	int A[MAX],n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	long long ans=mergeSort(A,n,0,n);
	printf("%ld\n",ans);
	
	return 0;
}


Measured memory_bytes: 3332
#include<iostream>
#include<algorithm>
using namespace std;
long long maxn1,maxn2,minn1=1e18,minn2=1e18,ans=1e18,minn3=1e18,maxn3;
struct node
{
	long long a,b;
	bool operator < (const node &s)const
	{
		return a<s.a;
	}
};
node tree[10000001];
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>tree[i].a>>tree[i].b;
		if (tree[i].a>tree[i].b)
			swap(tree[i].a,tree[i].b);
		minn1=min(minn1,tree[i].a);
		maxn1=max(maxn1,tree[i].a);
		minn2=min(minn2,tree[i].b);
		maxn2=max(maxn2,tree[i].b);
	}
	ans=(maxn2-minn2)*(maxn1-minn1);
	sort(tree+1,tree+n+1); 
	for (int i=1;i<=n;++i)
	{
		minn3=min(minn3,tree[i].b);
		maxn3=max(maxn3,tree[i].b);
		if (i!=1&&i!=n)
			ans=min(ans,(max(maxn3,tree[n].a)-min(minn3,tree[i+1].a))*(maxn2-minn1));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
  int k;
  cin >> k;
  
  ll ans = 0;
  REP(i,k){
    REP(j,k){
      REP(l,k){
        ans += GCD(GCD((i+1), (j+1)),GCD((j+1), (l+1)));
      }
    }
  }
  
  cout << ans << endl;
  
}


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

int main(){
    int N;
    int r = 0;
    cin >> N;
    vector<char> c(N);
    for (int i = 0; i < N; i++){
      cin >> c[i];
      if (c[i] == 'R') r++;
    }
    int times = 0;
    for (int i = 0; i < r; i++){
      if (c[i] == 'W') times++;
    }
    cout << times << endl;
}


Measured memory_bytes: 3612
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 K,X;
	cin >> K >> X;
	FOR(i, X - K + 1, X + K)
	{
		cout << i << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll H, W;
ll a[88][88], b[88][88], c[88][88];
ll dp[88][88][88*88];

int main(void) {
  cin >> H >> W;
  ll i, j, k;
  
  for(i=0; i<H; i++) for(j=0; j<W; j++) cin >> a[i][j];
  for(i=0; i<H; i++) for(j=0; j<W; j++) cin >> b[i][j];
  for(i=0; i<H; i++) for(j=0; j<W; j++) c[i][j]=abs(a[i][j]-b[i][j]);
  
  dp[0][0][c[0][0]]=1;
  for(i=0; i<H; i++) {
    for(j=0; j<W; j++) {
      for(k=0; k<85*85; k++) {
        chmax(dp[i+1][j][k+c[i+1][j]], dp[i][j][k]);
        chmax(dp[i+1][j][abs(k-c[i+1][j])], dp[i][j][k]);
        chmax(dp[i][j+1][k+c[i][j+1]], dp[i][j][k]);
        chmax(dp[i][j+1][abs(k-c[i][j+1])], dp[i][j][k]);
      }
    }
  }
  
  for(i=0; i<85*85; i++) {
    if(dp[H-1][W-1][i]) {
      pt(i);
      return 0;
    }
  }
}








Measured memory_bytes: 430976
def answer():
    H, W, K = map(int, input().split())
    matrix_in = [input() for _ in range(H)]
    matrix_out = [[0 for _ in range(W)] for _ in range(H)]

    skip_list = []
    first_exist = []
    idx = 0
    for h, row in enumerate(matrix_in):
        berry_in_row = 0

        if '#' not in row:
            skip_list.append(h)
        else:
            idx += 1
            first_exist.append(h)
            for w, item in enumerate(row):
                if item == '#':
                    berry_in_row += 1
                    if berry_in_row > 1:
                        idx += 1
                matrix_out[h][w] = idx

    first_exist = first_exist[0]
    if first_exist != 0:
        for h in range(first_exist):
            matrix_out[h] = matrix_out[first_exist]

    for h in skip_list:
        if h < first_exist:
            continue
        matrix_out[h] = matrix_out[h-1]

    for row in matrix_out:
        print(*row)


if __name__ == '__main__':
    answer()


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

using namespace std;

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

  set<int> st;
  int ans = c;
  while (true) {
    int d = c % (a + b);
    if (d <= a) {
      ans = c;
      break;
    }
    if (st.find(d) != st.end()) {
      ans = -1;
      break;
    }
    st.insert(d);
    c += 60;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll N, A, B, C, D;
string s;

int main() {
    cin >> N >> A >> B >> C >> D;
    cin >> s;
    FOR(i, A, max(C, D) - 2) {
        if (s[i] == '#')
            if (s[i] == s[i + 1]) {
                cout << "No" << endl;
                return 0;
            }
    }
    if (C > D) {
        bool ac = false;
        if (s[B] == '.' && s[B - 2] == s[B])ac = true;
        else
            FOR(i, B, D - 1) {
                if (s[i] == '.' && s[i - 1] == s[i] && s[i] == s[i + 1]) {
                    ac = true;
                }
            }
        if (!ac) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
(defparameter N (read))
(defparameter *lst* '())
 
(loop for i from 1 to N do
      (defparameter name (read))
      (defparameter value (read))
      
      (push `(,name ,value ,i) *lst*))
 
(defparameter answer
  (sort (copy-list *lst*)
        #'(lambda (x y) (or (string< (car x) (car y))
                            (and (string= (car x) (car y))
                                 (> (cadr x) (cadr y)))))))
 
(dolist (v answer) (print (third v)))

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

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

ll N;
ll A[200005];
map<ll,ll> cnt;
ll ans;

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

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

    for (int i = N;i >= 1;i--){
        ans += cnt[-(A[i]+i)];
        cnt[A[i]-i]++;
        //cout << A[i]-i << endl;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 27836
use std::fmt::Write;

fn main(){
    let mut sc = Scanner::new();
    let n = sc.next();
    let mut x = vec![0i64; n];
    for i in 0..n {
        x[i] = sc.next();
    }
    let mut d = vec![0i64; n-1];
    for i in 0..n-1 {
        d[i] = x[i+1] - x[i];
    }
    let m = sc.next();
    let k = sc.next();
    let mut perm:Vec<_> = (0..n-1).collect();
    for _ in 0..m {
        let a = sc.next::<usize>() - 1;
        perm.swap(a-1, a);
    }
    let perm2 = pow(&perm, k);
    let mut res = vec![0i64; n-1];
    for i in 0..n-1 {
        res[i] = d[perm2[i]];
    }

    let mut ans = String::new();
    let mut cur = x[0];
    write!(&mut ans, "{}\n", cur).unwrap();
    for i in 0..n-1 {
        cur += res[i];
        write!(&mut ans, "{}\n", cur).unwrap();
    }

    print!("{}", ans);
}

fn pow(perm: &Vec<usize>, k: usize) -> Vec<usize> {
    if k == 0 {
        (0..perm.len()).collect()
    } else if k%2 == 1 {
        let x = pow(perm, k-1);
        prod(&x, &perm)
    } else {
        let x = pow(perm, k/2);
        prod(&x, &x)
    }
}

fn prod(a: &Vec<usize>, b: &Vec<usize>) -> Vec<usize> {
    let n = a.len();
    let mut res = vec![0; n];
    for i in 0..n {
        res[i] = a[b[i]];
    }
    res
}

#[allow(dead_code)]
struct Scanner {
    buf: std::collections::VecDeque<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.buf.pop_front().and_then(|s| s.parse::<T>().ok())
    }

    fn ok(&mut self) -> bool {
        self.read() && !self.buf.is_empty()
    }

    fn eof(&mut self) -> bool {
        !self.ok()
    }

    fn read(&mut self) -> bool {
        while self.buf.is_empty() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    _ => return false,
                }
            }
            self.buf = st.split_whitespace().map(|x| x.to_string()).collect();
        }
        true
    }
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  for (int i=0; i<n; i++){
    cin >> h[i];
  }
  
  reverse(h.begin(),h.end());
  
  int ans = 0;
  int cnt = 0;
  
  for (int i=1; i<n; i++){
    if (h[i-1] <= h[i]) cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n;
int x[200010];
int y[200010];

const ll inf = 1ll<<60;
ll F(){
	ll maxx=-inf, minx=inf;
	ll maxy=-inf, miny=inf;
	for(int i=1; i<=n; ++i){
		ll cx=x[i], cy=y[i];
		if(cx>cy) swap(cx, cy);
		maxx=max(maxx, cx);
		minx=min(minx, cx);
		
		maxy=max(maxy, cy);
		miny=min(miny, cy);
	}
	return (maxx-minx) * (maxy-miny);
}

pp d[400010];
map<int,int> cnt;
int dis;
void add(int x){ dis+=!cnt[x]++; }
void rem(int x){ dis-=!--cnt[x]; }
ll G(){
	for(int i=1; i<=n; ++i){
		d[i] = {x[i], i};
		d[n+i] = {y[i], i};
	}
	sort(d+1, d+2*n+1);
	ll co = d[2*n].x - d[1].x;
	ll ans = inf;
	int r=0;
	for(int i=1; i<=2*n; ++i){
		while(r<2*n && dis<n) add(d[++r].y);
		if(dis == n) ans = min(ans, 1ll*d[r].x-d[i].x);
		rem(d[i].y);
	}
	return co*ans;
}

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(x[i], y[i]);
	printf("%lld\n", min(F(), G()));
    return 0;
}


Measured memory_bytes: 14336
function Main(input) {
    input = input.split(" ");

    var AB = parseInt(input[0], 10);
    var BC = parseInt(input[1], 10);
    var CA = parseInt(input[2], 10);
   
    var S = AB * BC/2;
    console.log(S);
}  

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n ,k ,q; cin >> n >> k >> q;
    VI ten(n,k-q);
    rep(i,q){
        int x; cin >> x;
        ten[x-1]++;
    }
    rep(i,n){
        if(ten[i] > 0) Yes;
        else No;
    }
    
    return 0;
}

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

int N;

int H[303], A[303], B[303];
long long dp[301][301][302];

map<int, int> M;

long long solve(int pos, int K, int prev)
{
    if(pos > N)
        return 0;

    if(dp[pos][K][prev] != -1)
        return dp[pos][K][prev];
    
    long long ans = solve(pos + 1, K, B[pos]) + max(0, H[pos] - A[prev]);

    if(K)
        ans = min(ans, solve(pos+1, K-1, prev));

    return dp[pos][K][prev] = ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int K;
    cin >> N >> K;

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

    M[0];
    int k = 0;

    for(auto &it : M)
    {
        it.second = k++;
        A[it.second] = it.first;
    }

    for(int i=1; i<=N; i++)
        B[i] = M[ H[i] ];

    if(K == N)
    {
        cout << 0 << "\n";
        return 0;
    }

    memset(dp, -1, sizeof(dp));
    cout << solve(1, K, 0) << "\n";
    return 0;
}


Measured memory_bytes: 214016
// https://atcoder.jp/contests/dp/tasks/dp_z
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

template <const int MAXN, class T, class Comparator = less<T>> struct ConvexHullTrick {
    Comparator cmp; T M[MAXN], B[MAXN]; int front = 0, back = 0;
    void addLine(T m, T b) { // in non decreasing order of slope, as sorted by the comparator
        while (back >= 2 && (m - M[back - 1]) * (B[back - 2] - B[back - 1]) >= (b - B[back - 1]) * (M[back - 2] - M[back - 1])) back--;
        while (back >= 1 && !cmp(m, M[back - 1]) && !cmp(M[back - 1], m) && !cmp(b, B[back - 1])) back--;
        M[back] = m; B[back++] = b;
    }
    T getMax(T x) { // in non decreasing order of x, regardless of comparator
        while (front < back - 1 && !cmp(M[front + 1] * x + B[front + 1], M[front] * x + B[front])) front++;
        return M[front] * x + B[front];
    }
    void clear() { front = back = 0; }
};

const int MAXN = 2e5 + 5;

int N;
ll C, H, dp;
ConvexHullTrick<MAXN, ll, greater<ll>> cht;

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // freopen("err.txt", "w", stderr);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> C;
    for (int i = 0; i < N; i++) {
        cin >> H;
        cht.addLine(-2 * H, H * H + (dp = i == 0 ? 0 : H * H + C + cht.getMax(H)));
    }
    cout << dp << nl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

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

using namespace std;

int main(){
    int n;
    cin >> n;
    map<string, int> count;
    long long ans = 0;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += count[s];
        count[s]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136