akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst;
    Weight weight;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
 
void add_edge(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }
 
Edge double_sweep(const Graph &g, int s = 0) {
    static const Weight INF = std::numeric_limits<Weight>::max() / 8;
    static const auto bfs = [](const Graph &g, int s, std::queue<int> &q, std::vector<int> &dist) {
        while(q.size()) q.pop();
        q.push(s);
        int n = g.size();
        dist.assign(n, INF);
        dist[s] = 0;
        while(q.size()){
            int u = q.front();
            q.pop();
            for(auto &e : g[u]){
                int v = e.dst;
                if(dist[v] == INF){
                    dist[v] = dist[u] + e.weight;
                    q.push(v);
                }
            }
        }
        return dist;
    };
    std::vector<Weight> dist;
    std::queue<int> q;
    bfs(g, s, q, dist);
    int n = g.size(), u = -1, v = -1;
    for (int i = 0; i < n; i++)
        if (dist[i] != INF && (u == -1 || dist[i] > dist[u])) u = i;
    bfs(g, u, q, dist);
    for (int i = 0; i < n; i++)
        if (dist[i] != INF && (v == -1 || dist[i] > dist[v])) v = i;
    Weight d = dist[v];
    if (u > v) std::swap(u, v);
    return Edge(u, v, d);
}
 
int main(){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    int n;
    std::cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        std::cin >> a >> b;
        add_edge(g, a-1, b-1, 1);
    }
    int x = double_sweep(g).weight%3!=1;
    if(x){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;

    }
}

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

int main(){
  char c;cin >> c;
  if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o')cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
K = int(input())
A = [i for i in range(1, 10)]
if K <= 9:
  print(A[K-1])
else:
  K -= 9
  f = 1
  while f:
    B = []
    for a in A:
      k = a % 10
      if k != 0:
        B.append(a * 10 + k - 1)
        K -= 1
      if K == 0:
        print(B[-1])
        f = 0
        break
      B.append(a * 10 + k)
      K -= 1
      if K == 0:
        print(B[-1])
        f = 0
        break
      if k != 9:
        B.append(a * 10 + k + 1)
        K -= 1
      if K == 0:
        print(B[-1])
        f = 0
        break
    A = B

Measured memory_bytes: 73220
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int mod = 998244353;

using ll = long long;

ll N;
ll a[310], S;
ll dp[310][90010], dp2[310][90010];

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", a+i );

  rep( i, N )
    S += a[i];

  dp[0][0] = 1;
  dp2[0][0] = 1;

  rep( i, N ) rep( j, S+1 )
  {
    dp[i+1][j] = (dp[i+1][j] + dp[i][j]*2) % mod;
    dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % mod; 
  }

  rep( i, N ) rep( j, S+1 )
  {
    dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % mod;
    dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % mod; 
  }

  /*repi( j, (S+1)/2, S+1 )
    printf( "dp[%d][%d] = %lld\n", N, j, dp[N][j] );  

  printf( "dp2[%d][%d] = %lld\n", N, S/2, dp2[N][S/2] );*/

  ll ans = 1;

  rep( i, N )
    ans = (ans*3) % mod;

  repi( j, (S+1)/2, S+1 )
    ans = (ans - 3*dp[N][j] + mod) % mod;
    
  if( S % 2 == 0 )
    ans = (ans + 3*dp2[N][S/2]) % mod;

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 425472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vi> g(h + 2, vi(w + 2, -2));
  queue<pair<int, int>> q;
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    char c;
    cin >> c;
    if(c == '#') {
      g[i][j] = k;
      k--;
      q.push({i, j});
    } else
      g[i][j] = -1;
  }
  vi d = {-1, 1};
  while(!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    rep(k, 2) {
      int nj = j + d[k];
      if(g[i][nj] != -1) continue;
      g[i][nj] = g[i][j];
      q.push({i, nj});
    }
  }
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) if(g[i][j] != -1) q.push({i, j});
  while(!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    rep(k, 2) {
      int ni = i + d[k];
      if(g[ni][j] != -1) continue;
      g[ni][j] = g[i][j];
      q.push({ni, j});
    }
  }
  rep2(i, 1, h + 1) {
    rep2(j, 1, w + 1) cout << g[i][j] << ' ';
    cout << '\n';
  }
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int cnt = 0;
    int a = 0, b = 0, ab = 0;
    string s[n];
    rep(i,n) cin >> s[i];
    rep(i,n){
        rep(j,int(s[i].size()-1)){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') cnt++;
        }
        if(s[i][0] == 'B' && s[i][int(s[i].size())-1]  == 'A') ab++;
        else if(s[i][0] == 'B') b++;
        else if(s[i][int(s[i].size())-1] == 'A') a++;
    }
    // cout << a << " " << b << endl;
    // cout << cnt << endl;
    if(a == b && a == 0){
        cout << cnt + max(ab - 1,0) << endl;
    }else if(a == b && a != 0){
        cout << cnt + ab + min(a,b) << endl;
    }else if(a > b){
        cout << cnt + ab + min(a,b) << endl;
    }else{
        cout << cnt + ab + min(a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string a, b, c; cin >> a >> b >> c;
    (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) ? YES() : NO();
}

Measured memory_bytes: 256
<?php
while ($line = fgets(STDIN)) {
 $array[] = trim($line);
}
$a = $array[0];
$b = $array[1];

          if($a == 'SUN'){

              echo "7";

          }else if($a == 'MON'){

                echo "6";

            }else if($a == 'TUE'){

                  echo "5";
                }else if($a == 'WED'){
      
                      echo "4";
                    }else if($a == 'THU'){
          
                          echo "3";
                        }else if($a == 'FRI'){
              
                              echo "2";
                            }else if($a == 'SAT'){
                  
                                  echo "1";
                }
?>


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

vector <ll> primes;
ll max_prime;

ll N;
ll nf[10000001] = { 1, }; // for one



int main() {
	cin >> N;

	ll i, j;

	ll ans=0;

	for (i = 1; i <= N; i++) {
		nf[i] = 1;
	}

	for (i = 2; i <= N; i++) {
		for (j = i; j <= N; j += i) {
			nf[j]++;
		}
	}
	for (i = 1; i <= N; i++) {
		//cout << i << " " << nf[i] << endl;
		ans += i * nf[i];
	}

	cout << ans << endl;

}


Measured memory_bytes: 81252
class UnionFind:
    def __init__(self, n):
        self._n = n
        self._table = [-1]*n

    def _root(self, x):
        stack = []
        while self._table[x] >= 0:
            stack.append(x)
            x = self._table[x]
        for y in stack:
            self._table[y] = x
        return x
    
    def unite(self, x, y):
        x, y = self._root(x), self._root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self._table[x] += self._table[y]
        self._table[y] = x

    def same(self, x, y):
        return self._root(x) == self._root(y)

    def count_members(self, x):
        return -self._table[self._root(x)]

    def count_groups(self):
        return len({self._root(i) for i in range(self._n)})

    def __iter__(self):
        return (self._root(i) for i in range(self._n))

    def __str__(self):
        return str([self._root(i) for i in range(self._n)])

    def __repr__(self):
        return repr([self._root(i) for i in range(self._n)])

n, m, *AB = map(int, open(0).read().split())
uf = UnionFind(n)
for a, b in zip(AB[::2], AB[1::2]):
    uf.unite(a-1, b-1)
print(max(uf.count_members(group) for group in set(uf)))

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

bool is_prime(const unsigned n) {
  if (n % 2 == 0 || n % 3 == 0) {
    if (n == 2 || n == 3) {
      return true;
    }
    return false;
  }
  if (n == 1) {
    return false;
  }

  for (unsigned i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }

  return true;
}

// prime factorization (素因数分解)
// key: value of prime factor
// value: number of prime factor
std::map<ll, ll> prime_factorization(ll n) {
  std::map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト
vector<ll> get_divisors(const ll n) {
  vector<ll> divs;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      divs.push_back(i);
      if (i != n / i) {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

ll eular_phi(ll n) {
  ll ans = n;

  auto primes = prime_factorization(n);
  for (const auto& it : primes) {
    ans -= ans / it.first;
  }

  return ans;
}

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

  ll n;
  cin >> n;

  cout << eular_phi(n) << endl;

  return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n = 0;
	string s1,s2;
	cin >> s1 >> s2;
	for(int i = 0; i <= 2; i++){
		if(s1[i] == s2[i]){
			n++;
		}
	}
	cout << n;
}

Measured memory_bytes: 384
S,K=list(map(int, input().split()))
H=[]
for _ in range(S):
  H.append(int(input()))
H.sort()
INF=float('inf')
a=[INF]*(S-K+1)
for i in range(S-K+1):
  a[i]=H[i+K-1]-H[i]
print(min(a))

Measured memory_bytes: 77564
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long 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] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,D; cin >> N >> D;
    vector<vector<int> > X(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }
    int out=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int sum = 0;
            for(int k=0;k<D;k++){
                int tmp=X[i][k]-X[j][k];
                sum += tmp*tmp;
            }
            int a=1;
            while(a*a<=sum){
                if(a*a==sum){
                    out++;break;
                }
                a++;
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int[][] bingo = new int[3][3];
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        bingo[i][j] = sc.nextInt();
      }
    }

    int num = sc.nextInt();

    int[] readout = new int[num];
    for(int i = 0; i < num; i++){
      readout[i] = sc.nextInt();
    }
    int[][] punched = punch(bingo,num,readout);
    System.out.println(row(punched));
  }
  public static int[][] punch(int[][] bingo, int num, int[] readout){
    for(int i = 0; i < num; i++){
      for(int j = 0; j <3; j++){
        for(int k = 0; k < 3; k++){
          if(bingo[j][k] == readout[i]){
            bingo[j][k] = 0;
          }
        }
      }
    }
    return bingo;
  }
  public static String row(int[][] bunched){
    for(int i = 0; i < 3; i++){
      if(bunched[i][0] + bunched[i][1] + bunched [i][2] == 0){
        return "Yes";
      }
      if(bunched[0][i] + bunched [1][i] + bunched[2][i] == 0){
        return "Yes";
      }
    }
    if(bunched[0][0] + bunched[1][1] + bunched[2][2] == 0){
      return "Yes";
    }
    if(bunched[0][2] + bunched[1][1] + bunched[2][0] == 0){
      return "Yes";
    }
    return "No";
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    int i, j, k;

    for(i = 0; i < n; i++) {
        cin >> a[i];

    }
    int ans;
    if(n == 1) {
        ans = abs(a[0] - w);
    }
    else {
        ans = max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2]));
    }
    cout << ans;
    return 0;
}



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

enum inf = int.max;

void main() {
    int n, q;
    scan(n, q);

    auto st = SegmentTree!(int, min, inf)(n);

    foreach (_ ; 0 .. q) {
        int com, x, y;
        scan(com, x, y);

        if (com == 0) {
            st.assign(x, y);
        }
        else {
            st.query(x, y + 1).writeln;
        }
    }
}

struct SegmentTree(T, alias op, T initValue = 0) {
    import std.functional : binaryFun;

    alias f = binaryFun!(op);

    T[] _data;
    int _treeSize, _lineSize = 1;

    // 配列の要素数 n だけ与えて初期化
    this(int n) {
        while (_lineSize < n) {
            _lineSize *= 2;
        }
        _treeSize = 2*_lineSize - 1;
        _data = new T[](_treeSize);
        _data[] = initValue;
    }

    // 配列 a を与えて初期化
    this(T[] a) {
        auto n = a.length;
        while (_lineSize < n) {
            _lineSize *= 2;
        }
        _treeSize = 2*_lineSize - 1;
        _data = new T[](_treeSize);
        _data[] = initValue;

        _data[_lineSize - 1 .. _lineSize - 1 + n] = a[];

        foreach_reverse (i ; 0 .. _lineSize - 1) {
            _data[i] = f(_data[2*i + 1], _data[2*i + 2]);
        }
    }

    // a[i] = x
    void assign(int i, int x) {
        i += _lineSize - 1;
        _data[i] = x;

        while (i > 0) {
            i = (i - 1) / 2;
            _data[i] = f(_data[2*i + 1], _data[2*i + 2]);
        }
    }

    // a[i] = f(a[i], x)
    void act(int i, int x) {
        i += _lineSize - 1;
        _data[i] = f(_data[i], x);

        while (i > 0) {
            i = (i - 1) / 2;
            _data[i] = f(_data[2*i + 1], _data[2*i + 2]);
        }
    }

    alias add = act;

    // 要求区間 [a, b) に対して、対象区間 [l, r) の値を返す
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) {
            r = _lineSize;
        }
        if (a >= b) { // 要求区間が空である場合
            return initValue;
        }
        if (b <= l || r <= a) { // 要求区間が対象区間外の場合
            return initValue;
        }
        if (a <= l && r <= b) { // 要求区間が対象区間に含まれている場合
            return _data[k];
        }

        // どちらでもない場合は対象区間を２つに分けて再帰する

        auto leftValue = query(a, b, 2*k + 1, l, l + (r - l) / 2);
        auto rightValue = query(a, b, 2*k + 2, l + (r - l) / 2, r);

        return f(leftValue, rightValue);
    }
}
























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4252
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

int cnt[1000000], mx;
void add(int a) {
	cnt[a++]--;
	cnt[a]++;
	mx = max(mx, a);
}
void rev(int a) {
	cnt[a--]--;
	cnt[a]++;
	if(mx == a + 1 && !cnt[a + 1])
		mx--;
}

signed main() {
	EmiliaMyWife

	int n, m, e;
	cin >> n >> m >> e;
	vector<int> cntc(m + 1);
	vector<vector<int>> row(n + 1);
	int ans = 0;
	for(int i = 0, a, b; i < e; i++) {
		cin >> a >> b;
		cntc[b]++;
		row[a].push_back(b);
	}
	for(int i = 1; i <= m; i++) {
		mx = max(mx, cntc[i]);
		cnt[cntc[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		for(int a : row[i]) {
			rev(cntc[a]);
			cntc[a]--;
		}
		ans = max<int>(ans, mx + row[i].size());
		for(int a : row[i]) {
			add(cntc[a]);
			cntc[a]++;
		}
	}
	cout << ans << '\n';
			
	return 0;
}


Measured memory_bytes: 20892
#include "bits/stdc++.h"
using namespace std;
#define ll long long;

int main(){
	string S;
	cin >> S;
	if (S== "SUN"){
		cout << 7;
	}else if (S=="SAT"){
		cout <<1;
	}
	else if(S== "FRI"){
		cout << 2;
	}else if (S=="THU"){
		cout << 3;
	}else if (S=="WED"){
		cout << 4;
	}else if(S=="TUE"){
		cout << 5;
	}else if(S=="MON"){
		cout << 6;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int>
#define di             deque<int>
#define vpii           vector<pair<int,int>>
#define pi             pair<int,int>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define all(a)         a.begin(),a.end()
#define rall(a)        a.rbegin(),a.rend()
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x:a) cin>>x
#define endl           '\n'
#define ln             printf("\n");
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int best=0,num=0;
int32_t main()
{
    nitro
    int n,best=0,num=0;cin>>n;
    if(n==1) return puts("1")*0;
    for(int i=n;~i;--i)
    {
        if(i%2==0)
        {
            int a=i,c=0;
            while(a%2==0)
            {
                if(a==0)break;
                c++;
                a/=2;
            }
            if(c>best)
            {
                best=c;
                num=i;
            }
        }
    }
    cout<<num;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int main()
{
	int a=gi(),b=gi(),c=gi(),s=0,A,B,C;
	while (1)
		if ((a&1)||(b&1)||(c&1)) return printf("%d\n",s),0;
		else if (a==b&&a==c) return puts("-1"),0;
		else s++,A=a,B=b,C=c,a=(B+C)>>1,b=(A+C)>>1,c=(A+B)>>1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                      
#include <cstdio>                                                        
using namespace std;                                                     
                                                                         
int main() {                                                             
  while (true) {                                                         
    int H, W;                                                            
    cin >> H >> W;                                                       
    if (H==0 && W==0) {                                                  
      break;                                                             
    }                                                                    
    for (int i=0; i<H; i++) {                                            
      for (int j=0; j<W; j++) {                                          
        if (i>=1 && i<H-1 && j>=1 && j<W-1) {                            
          printf(".");                                                   
        } else {                                                         
          printf("#");                                                   
        }                                                                
      }                                                                  
      printf("\n");                                                      
    }                                                                    
    printf("\n");                                                        
  }                                                                      
  return 0;                                                              
}                                                                        
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                          

Measured memory_bytes: 2944
from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix
from operator import itemgetter

n = int(input())
xy = [list(map(int, input().split())) + [i] for i in range(n)]

edge = set()
for key in (itemgetter(0), itemgetter(1)):
    xy.sort(key=key)
    for (x1, y1, i1), (x2, y2, i2) in zip(xy, xy[1:]):
        d = min(abs(x1 - x2), abs(y1 - y2))
        edge.add((i1, i2, d))

u, v, c = zip(*edge)

graph = csr_matrix((c, (u, v)), shape=(n, n))
mst = minimum_spanning_tree(graph, overwrite=True).astype(int)
ans = mst.sum()
print(ans)


Measured memory_bytes: 82400
# Keyence 2020 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k=nm()
h=nl()
h.sort(reverse=True)
ans=0
for i in range(n):
    if i<=k-1:
        continue
    ans+=h[i]
print(ans)

Measured memory_bytes: 26024
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int num = 1 + K * 2;

            Console.WriteLine((N+num-1) / num);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  ll n, k;
  cin >> n >> k;
  vector<int> tel(n);
  rep(i, n) cin >> tel[i];

  vector<int> dst;

  int pos = 0;
  dst.push_back(pos);

  map<int, int> mp;
  mp[pos] = 0;

  ll offset = 0;

  while (true) {
    int newpos = tel[pos] - 1;
    if (mp.count(newpos) > 0) {
      offset = mp[newpos];
      break;
    }
    dst.push_back(newpos);
    offset++;
    mp[newpos] = dst.size() - 1;
    pos = newpos;
  }

  ll ans;
  if (k <= offset) {
    ans = dst[k];
  }
  else {
    ll k2 = k - offset;
    ll size2 = dst.size() - offset;
    ll q = k2 % size2;
    ans = dst[offset + q];
  }
  ans++;
  cout << ans << endl;

  return 0;
}


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


using namespace std;
const long long INF=1e12;

int main(){
    int N;
    long long a[100000]={0};
    long long dp[100001]={0};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    
    fill(dp,dp+N,INF);
    for(int i=0;i<N;i++){
        *lower_bound(dp, dp+N, a[i])=a[i];
    }
    cout<<lower_bound(dp, dp+N, INF)-dp<<endl;;
    
    /*
    int res=0;
    
    for(int i=0;i<N;i++){
        dp[i]=1;
        for(int j=0;j<i;j++){
            if(a[j]<a[i]){
                dp[i]=max(dp[i],dp[j]+1);
            }
        }
        res=max(dp[i],res);
    }
    
    
    cout<<res<<endl;
    */
    
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int mx = 0;
    rep(i, 0, n){
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    vector<int> k = a;
    sort(k.begin(), k.end());
    reverse(k.begin(), k.end());
    for (auto ai: a){
        if (ai != mx) cout << mx << endl;
        else cout << k[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, m;
    cin >> n >> m;
    
    if (n & 1) {
        for (int i = 1, j = n; i <= m; ++i, --j) {
            cout << i << " " << j << "\n";
        }
    }
    else {
        for (int i = 1, j = n-1; i <= m/2; ++i, --j) {
            cout << i << " " << j << "\n";
        }
        for (int i = n/2, j = n-i-1; i-n/2+1 <= (m+1)/2; ++i, --j) {
            cout << i << " " << j << "\n";
        }
    }
    
    return 0;
}

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

int n,x,ans=0;
 
inline int read(){
  	int X=0,w=0; 
	char ch=0;
  	while (ch<'0' || ch>'9'){
		w|=ch=='-';
		ch=getchar();
	}
  	while (ch>='0' && ch<='9') 
	    X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  	return w?-X:X;
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		ans+=x;	
	}
	printf("%d",ans-n);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *nil;

void insert(int key)
{
    Node *y, *node, *z = (Node*)malloc(sizeof(Node));
    z->key = key;
    z->left = nil;
    z->right = nil;
    node = root;
    y = nil;
    while(node != nil)
    {
        y = node;
        if(node->key > key){
            node = y->left;
        }
        else{
            node = y->right;
        }
    }
    z->parent = y;
    if(y == nil) root = z;
    else{
        if(y->key > key) y->left = z;
        else y->right = z;
    }
}

void preorder(Node *node)
{
    if(node != nil){
        printf(" %d", node->key);
        preorder(node->left);
        preorder(node->right);
    }
}

void inorder(Node *node)
{
    if(node != nil){
        inorder(node->left);
        printf(" %d", node->key);
        inorder(node->right);
    }
}

int main()
{
    root = nil;
    int n, key;
    char com[10];
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%s", com);
        if(com[0]=='i'){
            scanf("%d", &key);
            insert(key);
        }
        else{
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
}


Measured memory_bytes: 26064
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC"<<endl;
    else
    cout<<"ABC"<<endl;
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t
//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}




int main(){
    ll N; cin >> N;
    if(isPrime(N)){
        cout << 1 << endl;
        return 0;
    }
    map<ll, ll> M;
    for(ll i = 2; i <= N; i++ ){
        if(!isPrime(i)) continue;
        //cout << i << endl;
        bool flag = false;
        while(N % i == 0){
            N /= i;
            M[i]++;
            flag = true;
        }
        if(flag && isPrime(N)) {
            M[N]++;
            N = 1;
            break;
        }
        else if(N == 1) break;
    }
    ll ans = 0;
    for(auto m : M){
        ll cnt = 1;
        while(1){
            if(m.second >= cnt) {
                m.second -= cnt;
                cnt++;
                ans++;
            }
            else break;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
long long s[1005];

int min(long long  s[],int a,int b) //求两个数最小函数
{
	if(s[a]<=s[b])
		return a;
	else
		return b;
}

int searchmin(long long s[],int left,int right) //分治函数
{ if (left == right || (left+1) == right)  //剩下两个元素或一个元素
 {int min1=left;
  int min2=right;
  return min(s,min1,min2); }
 else
 {int middle = (left+right)/2;
  int min1 = searchmin(s,left,middle);
  int min2 = searchmin(s,middle+1,right);
  return(min(s,min1,min2));}}

int max(long long s[],int a,int b) //求两个数最大函数
{
	if(s[a]>=s[b])
		return a;
	else
		return b;
}

int searchmax(long long s[],int left,int right) //分治函数
{ if (left == right || (left+1) == right)  //剩下两个元素或一个元素
 {int max1=left;
  int max2=right;
  return max(s,max1,max2); }
 else
 {int middle = (left+right)/2;
  int max1 = searchmax(s,left,middle);
  int max2 = searchmax(s,middle+1,right);
  return(max(s,max1,max2));}}

int main()
{
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>s[i];
		int x,a[1005],b[1005],c[1005];
		cin>>x;
		for(i=1;i<=x;i++)
        {
            cin>>a[i]>>b[i]>>c[i];
            if(a[i]==0)
                cout<<s[searchmin(s,b[i],c[i]-1)]<<endl;
            else
                if(a[i]==1)
                cout<<s[searchmax(s,b[i],c[i]-1)]<<endl;
        }

	return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <stdio.h>
#include <cmath>

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

typedef long long ll;

using namespace std;

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


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

int main(){
  int n,a=0;cin>>n;
  vector<int> x(n,0);
  REP(i,n) cin>>x.at(i);
  REP(i,n){
    if(i%2) a-=x.at(i);
    else a+=x.at(i);
  }
  cout<<a<<" ";
  a/=2;
  for(int i=0;i<n-1;i++){
    cout<<(x.at(i)-a)*2<<" ";
    a=x.at(i)-a;
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "SUN") {
    cout << "7" << endl;
  }
  else if (s == "MON") {
    cout << "6" << endl;
  }
  else if (s == "TUE") {
    cout << "5" << endl;
  }
  else if (s == "WED") {
    cout << "4" << endl;
  }
  else if (s == "THU") {
    cout << "3" << endl;
  }
  else if (s == "FRI") {
    cout << "2" << endl;
  }
  else if (s == "SAT") {
    cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def lcs(s, t):
    n = len(s)
    m = len(t)
    # dp[i][j] := 0-indexでsのi-1文字目までとtのj-1文字目までとのlcsの長さ
    # dp[0][0]は空文字を見ていると考えるからdp[0][0] = 0
    # dp[n][m] := sのn-1文字目まで（0-indexなのでsの末尾）とtのm-1文字目まで(0-indexなのでtの末尾)
    dp = [[0]*(m+1) for _ in range(n+1)]

    for i in range(n):
        for j in range(m):
            # 0-indexでsのi文字目とtのj文字目が等しいなら斜めに移動する
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            # 異なるなら左または上のmaxをとる
            else:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    res = ""
    while n != 0 and m != 0:  # どちらかが0になったら終わり，dp[0][*]及びdp[*][0]は必ず0なので
        # 上から遷移している場合，nをデクリメントしてよい
        if dp[n][m] == dp[n-1][m]:
            n -= 1
        # 左から遷移している場合，mをデクリメントしてよい
        elif dp[n][m] == dp[n][m-1]:
            m -= 1
        # 左でも上でもなく，左上からの遷移の場合，共通文字
        else:
            n -= 1
            m -= 1
            # 後ろから復元しているので以下のようにする
            res = s[n] + res
    return res


S = input()
T = input()
print(lcs(S, T))


Measured memory_bytes: 111452
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cast static_cast
#define ll long long int
#define v vector
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pair p
using namespace std;
ll modF=1e9+7;
ll INF=1e12;

void solve(){
	ll n,w;
	cin>>n>>w;
	v<ll> wa(n+1);
	v<ll> va(n+1);
	ll sum=0;
	for(int i=1;i<n+1;i++){
		cin>>wa[i]>>va[i];
		sum+=va[i];
	}
	v<v<ll>> dp(n+1,v<ll>(sum+1));
	for(int i=0;i<=n;i++){
		for(int j=0;j<=sum;j++){
			if(j==0){
				dp[i][j]=0;
			}
			else if(i==0){
				dp[i][j]=INF;
			}
			else{
				if(va[i]<=j)
					dp[i][j]=min(dp[i-1][j],wa[i]+dp[i-1][j-va[i]]);
				else
					dp[i][j]=dp[i-1][j];
			}
		}
	}
	ll ans=0;
	for(int i=sum;i>0;i--){
		if(dp[n][i]<=w){
			ans=i;
			break;
		}
	}
	cout<<ans<<"\n";
}

int main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 83044
#include<stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a ,&b ,&c ,&d);
    int i;
    for(i=0;i<100;i++){
        c=c-b;
        if(c<=0){
            printf("Yes");
            goto lavel;
        }
        a=a-d;
        if(a<=0){
            printf("No");
            goto lavel;
        }
    }
    lavel:
    return 0;
}

Measured memory_bytes: 1732
package main

import (
	"fmt"
)

func main() {

	var N int

	fmt.Scan(&N)

	B := SliceInt(N - 1)

	for i := 0; i < N-1; i++ {

		fmt.Scan(&B[i])

	}

	result :=0

	result += B[0]+B[N-2]

	for i:=1;i<=N-2;i++{

		result += min(B[i-1],B[i])
	}

	fmt.Println(result)

}

// return min
func min(a,b int) int{

	if a>b{

		return b
	}

		return a	
 
}

//SliceInt 引数サイズのSliceを返す
func SliceInt(a int) []int {

	IntSample := make([]int, a)

	return IntSample

}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)
#define MOD 1000000007

int now,n;


int main(){
  string s;cin>>s;
  int anum=0;
  int bcflg=0;
  ll score=0LL;
  int n=s.length();
  REP(i,n){
    if (s[i]=='A'){
      anum++;
    }else{
      if (anum!=0){
        if (s[i]=='B'){
          if (i<n-1){
            if (s[i+1]=='C'){
              score+=anum;
              i+=1;
            }else{anum=0;}
          }
        }else{anum=0;}
      }
    }


  }


cout<<(score)<<endl;
  return 0;
}

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

 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
 
    int n, ans = 0;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        v.push_back(c);
    }

    for(int i = 1; i < n-1; i++){
        if((v[i] > v[i-1] and v[i] < v[i+1]) or (v[i] < v[i-1] and v[i] > v[i+1])) 
            ans++;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
n,x,y = map(int,input().split())

ans = [0]*n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if i <= x and j >= y:
            a = abs(j-i)-abs(y-x)+1
            b = abs(i-x)+abs(j-y)+1
            ans[min(a,b)] += 1
        else:
            c = abs(x-i)+abs(y-j)+1
            d = abs(j-i)
            ans[min(c,d)] += 1

for i in range(1,n):
    print(ans[i])


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; 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)
typedef long long ll;
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; }

int A[105];

int main(){
    int N;
    cin >> N;
    rep(i, N) cin >> A[i];
    bool ok = true;
    rep(i, N){
        if (ok && A[i] % 2 == 0){
            ok = (A[i] % 3 == 0) || (A[i] % 5 == 0);
        }
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    i64 N, M;
    cin >> N >> M;
    i64 ans = 0;
    vector<set<int>> edge(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].insert(b);
        edge[b].insert(a);
    }
    vector<int> color(N, -1);
    queue<int> q;
    q.push(0);
    color[0] = 0;
    while(q.size()) {
        int a = q.front();
         q.pop();
        for(auto b : edge[a]) {
            if(color[b] < 0) {
                color[b] = !color[a];
                q.push(b);
            } else if (color[b] == color[a]) {
                ans = (N * (N - 1)) / 2 - M;
                cout << ans << endl;
                return 0;
            }
        }
    }
    i64 A = 0, B = 0;
    for(int i = 0; i < N; i++) {
        if(color[i]) A++;
        else B++;
    }
    ans = A * B - M;
    cout << ans << endl;
    return 0;
}

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

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int x = line[0];
            int y = line[1];
            Console.WriteLine(getN(x) == getN(y) ? "Yes" : "No");
        }

        public static int getN(int a)
        {
            int[] array = new int[] { 4, 6, 9, 11 };
            int group = 0;
            if (a == 2)
            {
                group = 1;
            }
            else if (array.Contains(a))
            {
                group = 2;
            }
            else
            {
                group = 3;
            }
            return group;
        }
    }
}

Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    class P
    {
        public int index;
        public List<int> ads;
        public P(int index)
        {
            this.index = index;
            ads = new List<int>();
        }
    }
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ps = new P[nm[0]];
        for(var i = 0; i < nm[0]; i++)
            ps[i] = new P(i);
        for(var i = 0; i < nm[1]; i++)
        {
            var ab = Array.ConvertAll(ReadLine().Split(' '),int.Parse);
            ps[ab[0]-1].ads.Add(ab[1]-1);
            ps[ab[1]-1].ads.Add(ab[0]-1);
        }
        var isPossi = false;
        foreach (var d in ps[nm[0] - 1].ads)
        {
            if (ps[d].ads.Contains(0)) { isPossi = true; break; }
        }
        WriteLine(isPossi ? "POSSIBLE" : "IMPOSSIBLE");
    }
}


Measured memory_bytes: 44468
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll c[10][10];
ll ans;

int main(){
  int n;
  cin >> n;
  REP(i,1,n+1){
    int temp=i;
    int front=0,back=temp%10;
    while(temp>=10){
      temp/=10;
    }
    front=temp;
    c[front][back]++;
  }
  rep(i,10)rep(j,10)ans+=c[i][j]*c[j][i];
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
for i in range(10000):
  x = input().split()
  a = int(x[0])
  op = x[1]
  b = int(x[2])
  if op == "+":
    A = a + b
    print(A)
  elif op == "-":
    B = a - b
    print(B)
  elif op == "*":
    C = a * b
    print(C)
  elif op == "/":
    D = a // b
    print(D)
  elif op == "?":
    break


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

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int main(){
    int n, t, a;
    scanf("%d%d", &n, &t);
    int last = 0, ans = 0;
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        if(last < a) ans += t;
        else ans += t-(last-a);
        last = max(last, a+t);
    }   
    printf("%d\n", ans);
}

Measured memory_bytes: 256