akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,a,b;
  while(cin >> x >> a >> b){
    TSTART();
    string ans;
    if(abs(x-a) < abs(x-b)){
      ans = "A";
    }else{
      ans = "B";
    }
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    while(N > 0) {
        if(N % 10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        N = N / 10;
    }

    cout << "No" << endl;

    return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, w; std::cin >> h >> w;
  string grid[h+1];
  rrep(i, h) std::cin >> grid[i];
  h++, w++;
  grid[0] = string(w-1, '#');
  rep(i, h) grid[i] = '#' + grid[i];
  vector<vi> dp(h*w, vi(h*w, inf));
  rep(i, h*w) dp[i][i] = 0;
  rep(i, h*w) if (grid[i/w][i%w] == '#') {
    rep(j, h*w) dp[i][j] = -1, dp[j][i] = -1;
  }
  rep(i, h*w) {
    int sx = i % w, sy = i / w;
    if (grid[sy][sx] == '#') continue;
    ssrep(dx, -1, 1) ssrep(dy, -1, 1) if (dx * dx + dy * dy == 1) {
      if (sy+dy < 0 || sy+dy >= h || sx+dx < 0 || sx+dx >= w) continue;
      if (grid[sy+dy][sx+dx] == '.') dp[i][(sy+dy)*w + (sx+dx)] = 1;
    }
  }
  rep(k, h*w) rep(i, h*w) rep(j, h*w) {
    if (grid[i/w][i%w] == '#' || grid[j/w][j%w] == '#' || grid[k/w][k%w] == '#')
      continue;
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[j][k]);
  }
  int ans = 0;
  rep(i, h*w) rep(j, h*w) {
    chmax(ans, dp[i][j]);
  }
  std::cout << ans << "\n";
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


vector<vector<ll>> dp(100, vector<ll>(2, -1));
int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  dp[45][0] = 0;

  for(int d = 44; d >= 0; --d) {
    ll mask = 1ll<<d;
    int num = 0;
    rep(i, n) if(a[i] & mask) ++num;

    if(dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1]+mask*max(num, n-num));
    
    if(dp[d+1][0] >= 0) {
      if(k & mask) {
        chmax(dp[d][1], dp[d+1][0]+mask*num);
        chmax(dp[d][0], dp[d+1][0]+mask*(n-num));
      }
      else chmax(dp[d][0], dp[d+1][0]+mask*num);
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;

}

Measured memory_bytes: 4008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.exec();
	}
	
	public void exec() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		int ans = Math.max(0, a - 2*b);
		System.out.println(ans);
	}
}


Measured memory_bytes: 24020
def main():
    n = int(input())
    prime_list = []
    i = 11
    while len(prime_list) < n:
        j = 2
        while j * j <= i:
            if i % j == 0:
                j = 0
                break
            j += 1
        if j:
            prime_list.append(i)
        i += 5
    print(" ".join(map(str, prime_list)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
def resolve():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    resolve()


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 100010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	
	int n;
	cin >> n;
	int a;
	set<int> si;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		si.insert(a);
	}

	if (si.size() == n)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String A = scan.next();
		String B = scan.next();
		String C = scan.next();

		if(A.substring(A.length()-1).equals(B.substring(0,1)) && B.substring(B.length()-1).equals(C.substring(0,1))){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    int v[30];
    for(int i=0;i<30;i++) v[i] = 0; 
    for(int i=0;i<=30/a;i++){
        for(int j=0;j<=30/b;j++){
            if(a*i + b*j < 30) v[a*i + b*j] = 1;
        }
    }

    //for(int i=0;i<30;i++) cout << "v[" << i << "] = " << v[i] << endl; 

    double maxd = 0;
    int ans_all = 100*a;
    int ans_s = 0;
    for(int i=1;i<30;i++){
        if(v[i] == 0) continue;
        for(int j=0;(j*c <= e*i && j*c + 100*i <= f);j++){
            for(int k=0;(j*c + k*d <= e*i && j*c + k*d + 100*i <= f);k++){
                if(maxd * (j*c + k*d + 100*i) < j*c + k*d){
                    maxd = j*c + k*d;
                    maxd /= j*c + k*d + 100*i;
                    ans_all = j*c + k*d + 100*i;
                    ans_s = j*c + k*d;
                }
            }
        }
    }

    cout << ans_all << " " << ans_s;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct compare
{
    bool operator()(const string& first, const string& second)
    {
        return first.size()>second.size();
    }
};
void solve()
{

    long long  n;
    cin>>n;
    vector<string>v;
    for(int long long i=0; i<n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        v.push_back(s);
    }
    map<string, long long> mp;
    for(int i=0; i<n; i++)
    {
        mp[v[i]]++;
    }
    long long  cnt=0;
    for(auto it:mp)
    {

       cnt+= ((it.second)*(it.second-1))/2;
    }
    cout<<cnt<<endl;


}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
}


Measured memory_bytes: 12020
#define DEBUG 0
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 6/22/2019, 9:11:11 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

ll A, B, C, D;

ll sub(ll K, ll X)
{
  return (K + (X - 1)) / X;
}

ll solve(ll K) // [0, K)
{
  ll L = C / gcd(C, D) * D;
  return K - sub(K, C) - sub(K, D) + sub(K, L);
}

int main()
{
  cin >> A >> B >> C >> D;
  // init();
  ll ans = solve(B + 1) - solve(A);
  cout << ans << endl;
}

Measured memory_bytes: 23680
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000009
ll fac[MAX],finv[MAX],inv[MAX];
typedef vector<vector<int> > Graph;
using P=pair<int,int>;

int dp[105][4][2];

int main(){
    string s;cin>>s;
    int n=s.size();
    int K;cin>>K;
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<2;k++){
                int nd=s[i]-'0';
                for(int d=0;d<10;d++){
                    int ni=i+1,nj=j,nk=k;
                    if(d!=0) nj++;
                    if(nj>K) continue;
                    if(k==0){
                        if(d>nd) continue;
                        if(d<nd) nk=1;
                    }
                    dp[ni][nj][nk]+=dp[i][j][k];
                }
            }
        }
    }
    int ans=dp[n][K][0]+dp[n][K][1];
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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 ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	string s;
	cin >> s;
	cout<< "ABC" << s << endl;

	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

#define j1 lskdjfla

int h, w, n;

int i1[100010];
int j1[100010];

int i2[100010];
int j2[100010];

bool on_edge(int i, int j) {
    bool res = (j == 0 || j == w || i == 0 || i == h);
    return res;
}

int f(int i, int j) {
    assert(on_edge(i, j));
    if (j == 0) return i;
    if (i == h) return h + j;
    if (j == w) return h + w + (h - i);
    return h + w + h + (w - j);
}

bool solve() {
    using pii = pair<int,int>;
    deque<pii> ei; // pos, idx
    rep(i, n) {
        if (on_edge(i1[i], j1[i]) && on_edge(i2[i], j2[i])) {
            int f1 = f(i1[i], j1[i]);
            int f2 = f(i2[i], j2[i]);
            ei.emplace_back(f1, i);
            ei.emplace_back(f2, i);
        }
    }
    sort(all(ei));

    int k = ei.size();
    deque<int> e;
    rep(i, k) e.push_back(ei[i].second);
    if (k <= 1) return true;
    int p = 0;
    while (p < k && e[p] != e[(p - 1 + k) % k]) ++p;
    if (p == k) return false;
    while (p) {
        int t = e.front();
        e.pop_front();
        e.push_back(t);
        --p;
    }
    set<int> se;
    stack<int> s;
    for (auto &x : e) {
        if (se.count(x)) {
            if (s.empty() || s.top() != x) return false;
            s.pop();
        } else {
            se.insert(x);
            s.push(x);
        }
    }
    return s.empty();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (cin >> h >> w >> n) {
        rep(i, n) {
            cin >> i1[i] >> j1[i] >> i2[i] >> j2[i];
        }
        cout << (solve() ? "YES" : "NO") << endl;
    }
    
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 998244353ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
long long modpow(long long a, long long n) { //累乗の余剰
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    std::cin >> n;
    VEC(ll,a,n);
    std::vector<int> c(100001);
    if(a[0]!=0){
        std::cout << 0 << std::endl;
        exit(0);
    }
    
    rep(i,n){
        c[a[i]]++;
        if(a[i]==0&&i!=0){
            std::cout << 0 << std::endl;
            exit(0);
        }
    }
    sort(all(a),greater<ll>());
    int m=a[0]+1;
    rep(i,m){
        if(c[i]==0){
            std::cout << 0 << std::endl;
            exit(0);
        }
    }
    
    
    ll ans=1;
    rep(i,m){
        ans*=modpow(c[i],c[i+1]);
        ans%=MOD;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
using namespace std;

#define ll long long
typedef pair<ll , ll > pii;
const int MOD = 998244353;
const int N=500004;

vector<int> BIT;

void update(int i, int add)
{
    while (i > 0 && i < BIT.size())
    {
        BIT[i] += add;
        i = i + (i & (-i));
    }
}

int sum(int i)
{
    int ans = 0;
    while (i > 0)
    {
        ans += BIT[i];
        i = i - (i & (-i));
    }

    return ans;
}
int findKthSmallest(int k)
{
    int l = 0;
    int h = BIT.size();
    while (l < h)
    {
        int mid = (l + h) / 2;
        if (k <= sum(mid))
            h = mid;
        else
            l = mid+1;
    }

    return l;
}

void insertElement(int x)
{
    update(x, 1);
}

void deleteElement(int x)
{
    update(x, -1);
}

int findRank(int x)
{
    return sum(x);
}

///


void min_self(int &a , int b){
    a=min(a,b);
}

int add(int x, int y)
{
    return (x + y) % MOD;
}

int sub(int x, int y)
{
    return add(x, MOD - y);
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
    int z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}

int inv(int x)
{
    return binpow(x, MOD - 2);
}

int fact[N];

int C(int n, int k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}
/////-----//////





int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
   int a,b; cin>>a>>b;
   cout<<a*b;


   return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int INF=(1e9);
const int maxn=(4e5)+10;
int n,m,ans[maxn];
int d[maxn],op[maxn];
vector<int> g[maxn],id[maxn];
void add(int x,int y,int z) {
	g[x].push_back(y);
	id[x].push_back(z);
}
pair<int,int> p[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	int x,y,z,flag;
	for (int i=1;i<=n;i++) read(d[i]),p[i]=make_pair(d[i],i),op[i]=-1;
	sort(p+1,p+n+1);
	for (int i=1;i<=m;i++) read(x),read(y),add(x,y,i),add(y,x,i);
	for (int I=1,u;I<=n;I++) {
		u=p[I].second;
		if (op[u]>-1) continue;
		flag=0;
		for (int i=0,v;i<g[u].size();i++) {
			v=g[u][i]; z=id[u][i];
			if (d[u]>=d[v]) {
				flag=1;
				if (op[v]==-1) op[v]=0,op[u]=1;
				else op[u]=op[v]^1;
				ans[z]=d[u];
				break;
			}
		}
		if (!flag) { printf("-1\n"); return 0; }
	}
	for (int i=1;i<=n;i++)
		if (op[i]) printf("B");
		else printf("W");
	printf("\n");
	for (int i=1;i<=m;i++) {
		if (!ans[i]) ans[i]=INF;
		printf("%d\n",ans[i]);
	}
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 34048
#include<iostream>
#include<stdio.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()

int func(int x){
    int temp, i=2;
    int val = 1;

    temp = x;

    if(x == 1) return 1;
    else{
        while(i<x){
            //printf("roop:%d\n",i);
            if(temp == 1){
                val = x;
                break;
            }
            else if(temp%i == 0){
                temp = temp/i;
            }
            else{
                i++;
                temp = x;
            }
        }
    }
    return val;
}

int main(void){
    int x=0; //input
    int val=0;
    int i;
    int max=0;

    std::cin >> x;

    for(i=0; i<=x; i++){
        val = func(i);
        if(max < val) max = val;
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var A = input[0];
            var B = input[1];
            var S = Console.ReadLine();
            var suc = true;

            if (S[A] != '-') suc = false;
            for (int i = 0; i < A; i++)
            {
                if (S[i] == '-') suc = false;
            }
            for (int i = A + 1; i < A + B; i++)
            {
                if (S[i] == '-') suc = false;
            }

            Console.WriteLine(suc ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int 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;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

int zero = 0;

signed main() {
	int h, w;
	cin >> h >> w;
	int mi = INF;

	if (h == 2 && w == 2) {

	}

	//縦
	for (int i = 1; i <= w - 1; i++) {
		int a = i * h;
		int b, c;
		if (i != w - 1) {
			b = (w - i) / 2 * h, c = ((w - i) - (w - i) / 2) * h;
			mi = min(mi, max({ a,b,c }) - min({ a,b,c }));
		}
		b = (w - i) * (h / 2), c = (w - i) * (h - h / 2);
		mi = min(mi, max({ a,b,c }) - min({ a,b,c }));
	}

	//横
	for (int i = 1; i <= h - 1; i++) {
		int a = i * w;
		int b, c;
		if (i != h - 1) {
			b = (h - i) / 2 * w, c = ((h - i) - (h - i) / 2) * w;
			mi = min(mi, max({ a,b,c }) - min({ a,b,c }));
		}
		b = (h - i) * (w / 2), c = (h - i) * (w - w / 2);
		mi = min(mi, max({ a,b,c }) - min({ a,b,c }));
	}

	cout << mi << endl;

	return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int caseNum = 1;
		while(true){
			int weightLimit = Integer.parseInt(br.readLine());

			if(weightLimit == 0){
				break;
			}

			int n = Integer.parseInt(br.readLine());
			Treasure[] treasures = new Treasure[n + 1];

			for(int i = 1; i <= n; i++){
				String[] tmpArray = br.readLine().split(",");
				treasures[i] = new Treasure(Integer.parseInt(tmpArray[0]), Integer.parseInt(tmpArray[1]));
			}

			//int[][] result = new int[n][weightLimit];
			Result[][] resultTable = new Result[n+1][weightLimit + 1];

			for(int i = 0; i <= weightLimit ; i++){
				resultTable[0][i] = new Result(0, 0);
			}
			
			for(int i = 1; i <= n ; i++){
				resultTable[i][0] = new Result(0, 0);
			}

			//int getCount = 0;
			for(int i = 1 ; i <= n ; i++){
				for(int j = 1; j <= weightLimit ; j++){
					//System.out.println(j);
					if(treasures[i].weight <= j ){
						//System.out.println("OK");
						int result1 = resultTable[i-1][j].value;
						int result2 = resultTable[i-1][j-treasures[i].weight].value + treasures[i].value;
						//System.out.println("result1 "+result1 + " result2 "+result2);
//						resultTable[i][j] = new Result( Math.max(, ), ;
						if(result1 >= result2){
							resultTable[i][j] = new Result(result1, resultTable[i-1][j].count);
						}
						else {
							resultTable[i][j] = new Result(result2, resultTable[i-1][j-treasures[i].weight].count + 1);
							//resultTable[i][j].selected[i] = true;
						}
					}
					else {
						resultTable[i][j] = new Result(resultTable [i-1][j].value, resultTable[i-1][j].count);
					}
				}
			}
			
			int weight = 0;
			int maxValue = resultTable[n][weightLimit].value;
			for(int j = 0; j <= weightLimit && maxValue != 0; j++){
				for(int i = 0; i <= n; i++){
					if(resultTable[i][j].value == maxValue){
						weight = j;
						break;
					}
				}
				if(weight != 0){
					break;
				}
			}

			System.out.println("Case "+caseNum+":");
			System.out.println(maxValue);
			System.out.println(weight);
			
			caseNum++;
		}

	}

}

class Result {
	int value;
	//boolean[] selected;

//	public Result (int value, boolean[] selected){
//		this.value = value;
//		this.selected = Arrays.copyOf(selected, selected.length);
//	}
	int count;

	public Result (int value, int count){
		this.value = value;
		this.count = count;
	}
//
//	public int countTreasure(){
//		int count = 0;
//		for(int i = 0; i < selected.length ; i++){
//			if(selected[i]){
//				count++;
//			}
//		}
//		return count;
//	}
}

class Treasure {
	int weight;
	int value;

	public Treasure(int v, int w){
		this.weight = w;
		this.value = v;
	}
}

Measured memory_bytes: 55056
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int b = 0, w = count(begin(s), end(s), '.');
    int ans = w;
    for(int i = 0; i < n; i++){
        if(s[i] == '#'){
            b++;
        }else{
            w--;
        }
        ans = min(ans, b + w);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
n,a,b=map(int,input().split())
a-=b
h=[]
s=0
for i in range(n):
    x=int(input())
    h.append(x)
    s+=x
h.sort(reverse=True)
x,z,f=0,2**(len(bin((s+b-1)//b))-2),0
while x!=z:
    if z-x==1:f=1
    y=(x+z)//2
    j=0
    for k in h:
        if k<y*b:break
        j+=(k-y*b+a-1)//a
    if f==0:
        if j>y:x=y
        else:z=y
    if f==1:
        if j>y:print(z)
        else:print(x)  
        break

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

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


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

int main() {
    int n;
    while (cin >> n) {
        long long ans , a;
        if (n % 2) {
            ans = 1;
            a = 4;
        }
        else {
            ans = 2;
            a = 6;
        }
        for (int i = 0; i < (n - 1) / 2; ++i) {
            ans += a;
            a *= 3;
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
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;

  
}


Measured memory_bytes: 3596
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let s1 = io.chars();
    let s2 = io.chars();
    let s3 = io.chars();
    println!(
        "{}{}{}",
        s1[0].to_string().to_uppercase().to_string(),
        s2[0].to_string().to_uppercase().to_string(),
        s3[0].to_string().to_uppercase().to_string()
    );
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
    M = B[N // 2]
    m = A[N // 2]
    print(M - m + 1)

else:
    M = (B[N // 2 - 1] + B[N // 2]) / 2
    m = (A[N // 2 - 1] + A[N // 2]) / 2
    print(int((M - m + 0.5) * 2))


Measured memory_bytes: 25408
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))*2
gr=n//math.gcd(n,m)
ans=0
for i in range(gr):
    test=[]
    for j in range(m):
        test.append(a[(i*m+j)%n])
    test.sort()
    ans+=test[-1]-test[0]
print(ans)


Measured memory_bytes: 5696
#include<stdio.h>
#define mod 1000000007

long long factorial[524288];

void cfact(){
    long long i;
    factorial[0]=1;
    factorial[1]=1;
    for(i=2;i<524288;i++){
        factorial[i]=factorial[i-1]*i;
        factorial[i]%=mod;
    }
}

long long power(long long a,long long b){
  long long x=1,y=a;
  while(b>0){
    if(b&1ll){
      x=(x*y)%mod;
    }
    y=(y*y)%mod;
    b>>=1;
  }
  return x%mod;
}
 
long long modular_inverse(long long n){
	return power(n,mod-2);
}

long long calcnCr(long long n,long long k){
	return (factorial[n]*(modular_inverse(factorial[k])*modular_inverse(factorial[n-k])%mod))%mod;
}

long long calc(long long a,long long b,long long c,long long d){
  long long n=a+b+c+d,r;
  r=calcnCr(n,a);
  r*=calcnCr(n-a,b);r%=mod;
  r*=calcnCr(n-a-b,c);
  return r%mod;
}

int main(){
  cfact();
  long long n,a,b,c,r=0,w;
  long long alpha,beta,gamma,delta,sigma;
  scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
  if(b%2==1){printf("0\n");return 0;}
  beta=b/2;
  for(alpha=0;alpha<=a;alpha++){
    gamma=a-alpha;
    for(delta=0;3*delta<=c;delta++){
      //printf("%lld %lld %lld %lld\n",alpha,beta,gamma,delta);
      w=calc(alpha,beta,gamma,delta);
      sigma=c-3*delta-gamma;
      if(sigma<0){continue;}
      if(beta==0){
        if(sigma==0){
          r+=w;r%=mod;
        }
      }
      else{
        r+=((w*calcnCr(sigma+(beta-1),beta-1))%mod);r%=mod;
      }
    }
  }
  printf("%lld\n",r);
  return 0;
}

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

namespace ABC118
{
    public class C
    {
        public void Solve()
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int res = A[0];
            for (int i = 1; i < N; i++)
            {
                res = Gcd(res, A[i]);
            }
            Console.WriteLine(res);
        }
        public int Gcd(int a, int b)
        {
            return (b < 0) ? Gcd(a, -b)
                 : (a < b) ? Gcd(b, a)
                 : (b > 0) ? Gcd(b, a % b)
                           : a;
        }
    }
}

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new ABC118.C().Solve();
        }
    }
}

Measured memory_bytes: 21216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[109];
  int k;
  for(int i=0;i<5;i++)cin>>a[i];
  cin>>k;
  int cnt=0;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(abs(a[i]-a[j])>k)cnt=true;
    }
  }
  if(cnt==false){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
N = gets.to_i
arr = gets.split.map(&:to_i)
arr = arr.sort!.reverse!
 
alice_score = 0
bob_score = 0
 
N.times do |n|
  n.even? ? alice_score += arr[n] : bob_score += arr[n]
end
 
puts alice_score - bob_score

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int x[200123];

int main()
{
	int n, a;
	cin >> n;
	rep(i, (n-1)) cin >> a, ++x[a];
	Rep(i, n) cout << x[i] << '\n';
	return 0;
}


Measured memory_bytes: 4376
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

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

  LL N, Z, W;
  cin >> N >> Z >> W;
  VI xs(N+1);
  xs[0] = W;
  REP(i,N) cin >> xs[i+1];

  VVL dp(2);
  dp[0] = VL(N+10, -INF);
  dp[1] = VL(N+10, INF);

  for(int i=N-1;i>=0;--i){
	dp[0][i] = abs(xs[N] - xs[i]);
	dp[1][i] = abs(xs[N] - xs[i]);
	for(int k=i+1;k<N;++k){
	  maxi(dp[0][i], dp[1][k]);
	  mini(dp[1][i], dp[1][k]);
	}
  }
  
  cout << dp[0][0] << endl;

  return 0;
}


Measured memory_bytes: 256
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    VS C(2);
    REP(i,2)
    {
        cin >> C[i];
    }
    VS B(2);
    REP(i, 2)
    {
        B[i] = C[i];
        reverse(ALL(C[i]));     
    }
    if (B[0]==C[1] && B[1]==C[0]) cout << "YES" << endl; 
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int max = Math.max(A + B, A - B);
			max = Math.max(max, A * B);
			out.println(max);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 21332
import java.util.*;
import java.util.Date;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        int[] count = new int[101];
        int a;
        int n = 0;
        while(true) {
            try {
                a = sc.nextInt();
            }catch(Exception e) {
                break;
            }
            count[a]++;
            n++;
        }
        int max = 0;
        for(int i = 0; i < n; i++) {
            if(max < count[i]) {
                max = count[i];
            }
        }
        for(int i = 0; i < n; i++) {
            if(max == count[i]) {
                list.add(i);
            }
        }
        Collections.sort(list);
        for(int i : list) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 25984