akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

const int mod = 998244353;

inline int _mul(int a, int b) {
    return (1ll * a * b) % mod;
}

inline int _sum(int a, int b) {
    return a + b < mod ? a + b : a + b - mod;
}

inline int _sub(int a, int b) {
    return a >= b ? a - b : a - b + mod;
}

inline void _inc(int &x, int y) {
    if ((x += y) >= mod) {
        x -= mod;
    }
}

inline void _dec(int &x, int y) {
    if ((x -= y) < 0) {
        x += mod;
    }
}

inline int _binpow(int x, int p) {
    int res = 1;
    int tmp = x;
    while (p > 0) {
        if (p & 1) {
            res = _mul(res, tmp);
        }
        tmp = _mul(tmp, tmp);
        p >>= 1;
    }
    return res;
}

const int N = 3e6 + 5;

int fact[N];
int rfact[N];

void precalc() {
    fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = _mul(fact[i - 1], i);
    }
    rfact[N - 1] = _binpow(fact[N - 1], mod - 2);
    for (int i = N - 2; i >= 0; i--) {
        rfact[i] = _mul(rfact[i + 1], i + 1);
    }
}

inline int CNK(int n, int k) {
    if (n < k) {
        return 0;
    }
    return _mul(fact[n], _mul(rfact[n - k], rfact[k]));
}

inline int F(int n, int k) {
    return CNK(n + k - 1, k);
}

int main() {

    precalc();

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    int n, m;

    cin >> n >> m;

    int res = 0;

    for (int i = m & 1; i <= m; i += 2) {
        _inc(
            res,
            _mul(
                CNK(n, i),
                F(n, (3 * m - i) / 2)
            )
        );
    }

    _dec(
        res,
        _mul(
            n,
            F(n, m - 1)
        )
    );

    cout << res << "\n";

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=(1<<20);
bool used[1252521];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
  }
  sort(a, a+n);
  REP(i, n-1){
    if(a[i]==a[i+1]){
      if(a[i]==1){
        cout<<0<<'\n';
        return 0;
      }
      for(int j=a[i]; j<INF; j+=a[i]){
        used[j]=true;
      }
    }
  }
  int ans=0;
  REP(i, n){
    if(used[a[i]]){
      continue;
    }
    ++ans;
    for(int j=a[i]; j<INF; j+=a[i]){
      used[j]=true;
    }
    // DEBUG(i);
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 5340
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: u64 = s.trim().parse().unwrap();
    if n % 2 != 0 {
        println!("0");
        return;
    }
    let mut m = n / 2;
    let mut ans = 0;
    while m > 0 {
        ans += m / 5;
        m /= 5;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
import sys
from collections import deque
sys.setrecursionlimit(10**9)

ans = 0

def calc(LL):
    global n,m,q,D,ans
    ret = 0
    for dd in D:
        a,b,c,d = dd[0],dd[1],dd[2],dd[3]
        if LL[b-1]-LL[a-1] == c:
            ret += d
    ans = max(ans,ret)

def func(LL):
    global n,m
    if len(LL) >= n:
        return calc(LL)
    for i in range(LL[-1],m+1):
        func(LL+[i])

n,m,q = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(q)]
for i in range(1,m+1):
    func([i])
print(ans)

Measured memory_bytes: 76544
//
//  main.cpp
//  4
//
//  Created by RISHAV SINGH MEHTA on 01/12/19.
//  Copyright © 2019 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...\n";
    long long int i,j,k,l;
    int n;
    string s;
    cin>>n;
    cin>>s;
    l=s.length();int a,b,c,aa,bb,cc;
    
    bool A[12]={false},ans[1002]={false};
    for (i=0; i<l; i++) {
        
        a= s[i] - '0';
        aa=a*100;
        
        if (A[a] == false) {
            
            bool B[12]={false};
            
            for (j=i+1; j<l; j++) {
                b= s[j] - '0';
                bb=b*10;
                if (B[b] == false) {
                    
                    for (k=j+1; k<l; k++) {
                        c= s[k] - '0';
                        cc=c*1;
                        int sum;
                        sum=aa+bb+cc;
                        ans[sum]=true;
                        
                        
                    }
                    
                }
                
                
                B[b]=true;
            }
            
        }
        
        A[a]=true;
    }
    int ggh=0;
    for (i=0; i<1000; i++) {
        if (ans[i] == true) {
            ggh=ggh+1;
        }
    }
    cout<<ggh<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: str):
    sum = 0
    for i in N:
        sum += int(i)
        if sum >= 9:
            sum -= 9
    print(YES if sum == 0 else NO)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: str
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73564
N = gets.to_i
A, B, C = 3.times.map{ gets.split.map(&:to_i).sort }
ans = B.inject(0) do |s,b|
  i = (A.bsearch_index{|a| a >= b } || N)
  j = N - (C.bsearch_index{|c| c > b } || N)
  s + i * j
end
puts ans



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

int main(){
  long long q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  h=min(2*q,h);
  s=min(2*h,s);
  if(2*s<=d){
    cout<<s*n<<endl;
  }
  else{
    cout<<d*(n/2)+s*(n%2)<<endl;
  }
  return 0;
}

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

int main(){
  long long int n,a,b;
  cin >> n >> a >> b;
  long long int x=0;
  if(a>b){
    cout << 0 << endl;
  }
  else{
    cout << max(x,(b-a)*(n-2)+1) << endl;
  }
}


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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(string, s);

    rep(i, 4) cout << s[i];
    cout << ' ';
    reps(i, 4, s.size() - 1) cout << s[i];
    output();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 main()
 {
   int n;
   cin>>n;
   vector<long long> v(n);
   for(int i=0;i<n;i++)cin>>v[i];
   for(int i=n-2;i>=0;i--)
   {
     if((v[i]-v[i+1])>1)
     {
       cout<<"No\n";
       return 0;
     }
     else if((v[i]-v[i+1])>0)
          v[i]--;
       
     
     
   }
   
   cout<<"Yes\n";
 }

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);

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

  int ball = 0;

  for (int i = N; 0 < i; i--) {
    int count = 0;
    for (int k = 1; k * i <= N; k++) {
      if (b[k * i - 1] == 1) {
        count++;
      }
    }
    if (count % 2 != a[i - 1]) {
      b[i - 1] = 1;
      ball++;
    }
  }

  cout << ball << endl;

  for (int i = 0; i < N; i++) {
    if (b[i] == 1) {
      cout << i + 1 << " " << endl;
    }
  }
  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int gcd(int x,int y){
  if(y==0)return x;
  if(x<=y) swap(x,y);
  if(x%y==0) return y;
  else return(gcd(y,x%y));//最大公約数
}


int main(){
    int k;
    cin >> k;
    int ans = 0;
    for(int i=1;i<k+1;i++){
        for(int j=1;j<k+1;j++){
            for(int p=1;p<k+1;p++){
                ans += gcd(i,gcd(j,p));
            }
        }
    }
    COUT(ans);
    return 0;
} 


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

int main() {
  int n,m;
  cin >> n >> m;
  int x, y;
  int dp[n+1];
  rep(i, n+1) dp[i] = 0;
  
  vector<int> ins(n+1, 0), outs(n+1,0), edges[n+1];
  
  rep(i,m) {
    cin >> x >> y;
    outs[x] ++;
    ins[y] ++;
    edges[x].push_back(y);    
  }
  stack<int> st;
  rep(i,n+1) if (ins[i]==0) st.push(i);
  
  int i;
  while(st.size()) {
    i = st.top();st.pop();
    for (int j: edges[i]) {
      dp[j] = max(dp[i]+1, dp[j]);
      ins[j]--;
      if (ins[j] == 0) st.push(j);
    }
    
  }
  int maxi=0;
  rep(i,n+1) maxi=max(maxi, dp[i]);
  cout << maxi;

}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
template<typename T> inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
string s;
int main(){
	cin>>s;
	puts((s[0]==s[s.length()-1])^(s.length()%2)?"First":"Second");
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
allpat=[]
todo=[[]]
while todo:
  pat=todo.pop()
  if len(pat)==n//2:
    allpat.append(pat)
    continue
  s=0
  if pat:s=max(pat)+1
  for i in range(s,n):
    todo.append(pat+[i])

def func(pat):
  # カードを最終的に偶奇どちらのidxになるかで分類
  # pat内のidxが最後に奇数のidxになるとする
  ablev=[]
  ablod=[]
  for i in range(n):
    if i in pat:
      if i%2==0:
        ablod.append([i,b[i]])
      else:
        ablod.append([i,a[i]])
    else:
      if i%2==0:
        ablev.append([i,a[i]])
      else:
        ablev.append([i,b[i]])
  ablev.sort(key=lambda x:x[1]*20+x[0])
  ablod.sort(key=lambda x:x[1]*20+x[0])
  now=0
  ary=[]
  for i in range(n//2):
    if ablev[i][1]>=now:
      now=ablev[i][1]
      ary.append(ablev[i][0])
    else:
      return -1
    if ablod[i][1]>=now:
      now=ablod[i][1]
      ary.append(ablod[i][0])
    else:
      return -1
  if n%2==1:
    if ablev[n//2][1]>=now:
      now=ablev[i][1]
      ary.append(ablev[n//2][0])
    else:
      return -1
  ret=0
  for i in range(n):
    for j in range(n-1,i,-1):
      if ary[j-1]>ary[j]:
        ary[j],ary[j-1]=ary[j-1],ary[j]
        ret+=1
  return ret

ans=float('inf')
for pat in allpat:
  t=func(pat)
  if t>=0:
    ans=min(ans,t)
print(ans if ans!=float('inf') else -1)


Measured memory_bytes: 16452
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
ans = min(a_list) + min(b_list)

for _ in range(M):
    x, y, c = map(int, input().split())
    S = a_list[x - 1] + b_list[y - 1] - c

    if ans > S:
        ans = S

print(ans)

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

int main(void) {
  string s;
  cin >> s;

  list<char> ret;
  for (const auto& c : s) {
    ret.push_back(c);
  }

  int Q, rev = 0;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int t;
    cin >> t;
    if (t == 1) {
      // reverse
      rev = rev ? 0 : 1;
    }
    else if (t == 2) {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        // add front c
        if (rev) ret.push_back(c);
        else ret.push_front(c);
      }
      else {
        // add back c
        if (rev) ret.push_front(c);
        else ret.push_back(c);
      }
    }
  }

  string out;
  for (const auto& c : ret) {
    out += c;
  }
  if (rev) reverse(out.begin(), out.end());
  cout << out << endl;

  return 0;
}

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

int main(void)
{
	std::string s;
	std::cin>>s;
	std::stack<int> S;
	int n = (int)s.size();
	for(int i=0;i<n;i++)
	{
		if(S.empty() || (s[S.top()] == s[i]))
		S.push(i);
		else S.pop();
	}
	std::cout<<(n - (int)S.size())<<"\n";
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  int n; cin >> n;
  vector<int> l(n + 1), r(n + 1);
  for(int i = 1; i <= n; ++i)
    cin >> l[i] >> r[i];
  ll res = 0;
  sort(l.rbegin(), l.rend());
  sort(r.begin(), r.end());
  for(int i = 0; i <= n; ++i){
    if(l[i] < r[i]) continue;
    res += l[i] - r[i];
  }
  cout << res * 2;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int dx[2][8] = { { 0, 1, 2, 3, 0, 1, 2, 3 }, { 0, 1, 0, 1, 0, 1, 0, 1 } };
int dy[2][8] = { { 0, 0, 0, 0, 1, 1, 1, 1 }, { 0, 0, 1, 1, 2, 2, 3, 3 } };

int dx2[4] = {1, 0, -1, 0};
int dy2[4] = {0, -1, 0, 1};

struct Point
{
	int x, y;
	Point(){};
	Point(int a, int b)
	{
		x = a;
		y = b;
	}
};

void solve()
{
	int w, h;
	while (cin >> w >> h, w || h)
	{
		vector< vector<int> > field(h + 1, vector<int>(w + 1));
		Point start, goal;
		cin >> start.x >> start.y >> goal.x >> goal.y;
		int n;
		cin >> n;
		for (int i = 0; i < n; ++i)
		{
			int c, d;
			Point p;
			cin >> c >> d >> p.x >> p.y;
			for (int j = 0; j < 8; ++j)
			{
				int nextX = p.x + dx[d][j];
				int nextY = p.y + dy[d][j];
				field[nextY][nextX] = c;
			}
		}
		if (field[start.y][start.x] != field[goal.y][goal.x])
		{
			cout << "NG" << endl;
			continue;
		}
		queue<Point> que;
		que.push(start);
		bool isOK = false;
		deque< deque<bool> > isUsed(h + 1, deque<bool>(w + 1));
		isUsed[start.y][start.x] = true;
		while (!que.empty())
		{
			Point p = que.front();
			que.pop();
			if (p.x == goal.x && p.y == goal.y)
			{
				isOK = true;
				break;
			}
			for (int i = 0; i < 4; ++i)
			{
				int nx = p.x + dx2[i];
				int ny = p.y + dy2[i];
				
				if ((1 <= nx && nx <= w) && (1 <= ny && ny <= h) && field[ny][nx] == field[start.y][start.x] && isUsed[ny][nx] == false)
				{
					isUsed[ny][nx] = true;
					que.push(Point(nx, ny));
				}
			}
		}
		if (isOK)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}
}

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

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};

bool chk(int x,int pos){return (bool)(x&(1<<pos));}
int Set(int x,int pos){return x=x|(1<<pos);}
int clr(int x,int pos){return x=x&~(1<<pos);}

ll n,m,a[16][16],dp[(1<<16)+2],b[(1<<16)+2];
vector<ll> v;

ll fn(ll mask)
{
    if(mask==0)return 0;
    ll &z=dp[mask];
    if(z!=-1)return z;
    ll i;
    z=0;
    for(i=mask;i>0;i=(i-1)&mask)
    {
        z=max(z,b[i]+fn(mask&~(i)));
    }
    return z;
}

int main()
{
    ll var;
    mem(dp,-1);
    sfl(n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            sfl(a[i][j]);
        }
    }
    m=1<<n;m--;
    for(i=m;i>0;i--)
    {
        v.clear();
        for(j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                v.pb(j);
            }
        }
        for(j=0;j<v.size();j++)
        {
            for(k=j+1;k<v.size();k++)
            {
                b[i]+=a[v[j]][v[k]];
            }
        }
    }
    z=fn(m);
    cout<<z<<endl;
}


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string S, T;
    cin >> S >> T;

    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  rep(i,s.size()-1){
    if (s.at(i+1)==s.at(i)) {
      cout<<"no"<<endl;
      break;
    }
    else if (i==s.size()-2) {
      cout<<"yes"<<endl;
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string S; cin >> S;
  ll N = S.length();
  S=S+'R';
  ll i_of_last_R = 0;
  ll i_of_first_L = N-1;
  ll cache[2]; 
  cache[0]=0; cache[1]=0;
  ll ans[N]={0};
  
  for(ll i=0; i<N; i++){
    if(S[i]=='R'){
      i_of_last_R=i;
      if(S[i+1]=='R'){
        ans[i]=0;
        cache[i%2]++;
      }else if(S[i+1]=='L'){
        i_of_first_L=i+1;
        ans[i_of_last_R]+=(cache[i_of_last_R%2]+1);
        ans[i_of_first_L]+=(cache[i_of_first_L%2] +1);
        cache[i_of_last_R%2]=0;
        cache[i_of_first_L%2]=0;
      }
    }else if(S[i]=='L'){
      if(S[i+1]=='R'){
        ans[i_of_last_R]+=cache[i_of_last_R%2];
        ans[i_of_first_L]+=cache[i_of_first_L%2];
        cache[i_of_last_R%2]=0;
        cache[i_of_first_L%2]=0;
      }else if(S[i+1]=='L'){
        ans[i+1]=0;
        cache[(i+1)%2]++;
      }
    }

  }
  for(ll j=0; j<N; j++){
    cout << ans[j] << ' ' ;
  }
  

}


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

#define inf 1e9+7
typedef long long ll;

void solve(int n,const vector<ll> &a){
    for(int i=0;i<n;i++){
        int sub=i+1;
        cout << "node " << sub << ":";
        cout << " key = " << a[i] << ",";
        if(i)cout << " parent key = " << a[sub/2-1] << ",";
        if(sub*2-1 < n)cout << " left key = " << a[sub*2-1] << ",";
        if(sub*2 < n)cout << " right key = " << a[sub*2] << ",";
        cout << " \n";
    }
}

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

    int n;
    cin >> n;
    vector<ll> a(n,inf);
    for(int i=0;i<n;i++)cin >> a[i];
    solve(n, a);
    return 0;
}



Measured memory_bytes: 3144
#include<stdio.h>
#include<string.h>

int main()
{
  int i,j,n1,n2,head;
  char S[102],SS[102];

  while(1){
    fgets(S,sizeof(S),stdin);
    if(S[0]=='.')break;
    head=0;
    for(i=0;i<strlen(S);i++){
      if(S[i]=='[' ||S[i]=='(' ||S[i]==')' ||S[i]==']'){
	SS[head++]=S[i];
      }
      if(S[i]==']' &&SS[head-2]=='[')head-=2;
      if(S[i]==')' &&SS[head-2]=='(')head-=2;
    }
    if(head==0)printf("yes\n");
    else printf("no\n");
    
  }
  
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	string s;
	cin>>s;
	int sum=0;
	int n=s.length();
	for(int i=0;i<n;i++){
		sum+=(s[i]-'0');
	}
	if(sum%9==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, K; cin >> n >> K;
  vector<long long> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];
  vector<long long> dp(n, 0);
  for (int i = 1; i < n; ++i) {
    dp[i] = LLONG_MAX;
    for (int j = i - 1; j >= max(i - K, 0); --j) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n - 1] << '\n';

}



Measured memory_bytes: 1792
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if (s.equals("Sunny") || s.equals("Rainy") || s.equals("Cloudy")) {
            if (s.equals("Sunny")) {
                System.out.println("Cloudy");
            } else if (s.equals("Cloudy")) {
                System.out.println("Rainy");
            } else {
                System.out.println("Sunny");
            }
        }
    }
}


Measured memory_bytes: 23252
<?php
fscanf(STDIN, "%d", $N);
$tree = [];
$cnt = [];
$paint = [];
$ones = [];
for ($i = 0; $i < $N - 1; $i++) {
    fscanf(STDIN, "%d %d", $a[$i], $b[$i]);
    $tree[$a[$i]][$b[$i]] = 1;
    $tree[$b[$i]][$a[$i]] = 1;
}
$max_num = 0;
$max_v = 0;
for ($i = 1; $i <= $N; $i++) {
    $cnt[$i] = count($tree[$i]);
	if ($max_num < $cnt[$i]) {
		$max_num = $cnt[$i];
		$max_v = $i;
	}
}
$ans = max($cnt);
echo $ans . PHP_EOL;
$stack = [$max_v];
$done = [];
$rr = 0;
while($stack) {
    // echo implode(" ", $stack) . PHP_EOL;
	$bool = false;
	$target = array_pop($stack);
	foreach ($tree[$target] as $partner => $dummy) {
	   // echo "partner {$partner}\n";
        for ($j = 1; $j <= $ans; $j++) {
			$rr++;
			$rr %= $ans;
            if (!isset($paint[$target][$rr]) && !isset($paint[$partner][$rr])) {
                $mmin = min($target, $partner);
                $mmax = max($target, $partner);
                $data[$mmin][$mmax] = $rr;
                $paint[$target][$rr] = 1;
                $paint[$partner][$rr] = 1;
                unset($tree[$target][$partner]);
                unset($tree[$partner][$target]);
    			$bool = true;
                break;
            }
        }
    	if (!isset($done[$partner])) {
			if ($cnt[$partner] === 1) {
				$done[$partner] = 1;
			} else {
    	    	array_push($stack, $partner);
			}
    	}

	}
	$done[$target] = 1;
}
$array = [];
for ($i = 0; $i < $N - 1; $i++) {
    $array[] = $data[$a[$i]][$b[$i]] + 1;
}
echo implode(PHP_EOL, $array);


Measured memory_bytes: 130804
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;
int main(){
	ll n;
	cin>>n;
	map <ll,ll> mp;
	for(ll i=0; i<n; i++){
		ll a;
		cin>>a;
		mp[a]++;
	}
	ll m;
	cin>>m;
	map <ll,ll> mp1;
	for(ll i=0; i<m; i++){
		ll b;
		cin>>b;
		mp1[b]++;
	}
	map<ll,ll>::iterator it;
	for(auto i : mp1){
		it=mp.find(i.first);
		if(it==mp.end()){
			cout<<"NO"<<endl;
			return 0;
		}
		else {
			if(i.second>it->second) {
				cout<<"NO";
				return 0;
			}
		}
	}
	cout<<"YES"<<endl;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, A, N);
  map<ll, int> m;
  each(x, A) {
    m[x]++;
  }
  vector<ll> v;
  each(x, m) {
    if (x.second >= 4) {
      v.push_back(x.first);
      v.push_back(x.first);
    } else if (x.second >= 2) {
      v.push_back(x.first);
    }
  }
  if (v.size() < 2) {
    print(0);
    return;
  }
  sort(all(v), greater<>());
  print(v[0] * v[1]);
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N, S;

int main() {
	cin >> N;
	for (ll i = 1; i*i <= N; ++i) {
		ll t = (N - i) / i;
		if (t) {
			if (t*i == N - i&&N%t == i)S += t;
		}
	}
	cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int HW_MAX = 300;
const int A_MAX = HW_MAX * HW_MAX;
int main (void) {
    int H, W;
    int D;
    int px[A_MAX + 1], py[A_MAX + 1];
    ll d[A_MAX + 1];
    int Q;

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> H >> W >> D;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int A;
            cin >> A;
            px[A] = j, py[A] = i;
        }
    }

    for (int i = 0; i <= H * W; i++) d[i] = 0;

    for (int i = D; i <= H * W; i++) {
        d[i] += d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
    }

    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <climits>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
    ll n;
    cin >> n;
    
    vector<ull> arr(n);
    for(ll i = 0; i < n; ++i)
        cin >> arr[i];
  
    sort(arr.begin(), arr.end());
    ull k = 0;
    
    while(arr.back() > (n - 1)) {
        ld Z = arr.back() - (n - 1);
        ld N = n;
        ull temp = ceil(Z / N);
        
        k += temp;
        
        for(ll i = 0; i < n - 1; ++i)
            arr[i] += temp;
        arr[n - 1] = arr[n - 1] - (temp * N);
        
        sort(arr.begin(), arr.end());
    }
    
    cout << k << endl;
    
    return 0;
}


Measured memory_bytes: 256
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	int n;
	while(1)
	{
		scanf("%d",&n); if(!n) return 0;
		vector<P>state(0);
		for(int i=1;i<=n;i++)
		{
			int t; scanf("%d",&t);
			if(i%2==1)
			{
				if(state.empty() || state[state.size()-1].second!=t)
				{
					state.pb(mp(1,t));
				}
				else
				{
					state[state.size()-1].first++;
				}
			}
			else
			{
				if(state[state.size()-1].second==t)
				{
					state[state.size()-1].first++;
				}
				else
				{
					int v=state[state.size()-1].first;
					state.pop_back();
					if(!state.empty()) state[state.size()-1].first+=(v+1);
					else state.pb(mp(v+1,t));
				}
			}
		}
		int ret=0;
		for(int i=0;i<state.size();i++) if(!state[i].second) ret+=state[i].first;
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
#define F first
#define S second
typedef long long ll;
using namespace std;

int main(){
	int N,ans;
	cin>>N;
	int A[100010];
	REP(i,0,N) cin>>A[i];
	int now=0;
	ans=1;
	REP(i,1,N){
		if(A[i]==A[i-1])continue;
		else if(A[i]>A[i-1]){
			if(now<0) {
				ans++;
				now=0;
			}
			else now++;
		}else{
			if(now>0) {
				ans++;
				now=0;
			}
			else now--;
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {

    int mi = INT_MAX;
    int L, R;
    cin >> L >> R;
    for (int i = L; i < min(R, L + 2019); ++i) {
        int x = i % 2019;
        for (int j = i + 1; j < min(R + 1, i + 2020); ++j) {
            int y = j % 2019;
            int z = x*y % 2019;
            smin(mi, z);
        }
    }
    cout << mi << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

typedef pair<int, int> P;
const int M = 1000000007;

vector<int> dijkstra(int s, vector<vector<P>> edge) {
    int n = edge.size();
    vector<int> dist(n, M);
    priority_queue<P, vector<P>, greater<P>> q;
    dist[s] = 0;
    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int d = p.first;
        for (auto& e : edge[p.second]) {
            if (dist[e.second] > p.first + e.first) {
                dist[e.second] = p.first + e.first;
                q.push(P(p.first + e.first, e.second));
            }
        }
    }
    return dist;
}


int main() {
    int n;
    cin >> n;
    vector<vector<P>> edge(n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        if (i != u) exit(1);
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            edge[i].push_back(P(c, v));
        }
    }
    vector<int> d = dijkstra(0, edge);
    for (int i = 0; i < n; ++i) {
        cout << i << " " << d[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 11728
#include<bits/stdc++.h>
using namespace std;
int p[10],q[10];
int a[10]={0,1,2,3,4,5,6,7,8,9};
int main(){
	int n;
	cin>>n;
	int cntp=0,cntq=0;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	for(int i=1;i<=n;i++){
		cin>>q[i];
	}
	int ans1,ans2;
	int cnt=0;
	do{
		cnt++;
		bool can1=1,can2=1;
		for(int i=1;i<=n;i++){
			if(p[i]!=a[i]){
				can1=0;
				break;
			}
		}
		for(int i=1;i<=n;i++){
			if(q[i]!=a[i]){
				can2=0;
				break;
			}
		}
		if(can1==1){
			ans1=cnt;
		}
		if(can2==1){
			ans2=cnt;
		}
	}while(next_permutation(a+1,a+n+1));
	cout<<abs(ans1-ans2);
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split(' ')))

ans = []
while(b):
    position = -1
    for i,x in enumerate(b):
        order = i + 1
        if order == x:
            position = i
    if position == -1:
        print(-1)
        exit()
    ans.append(b.pop(position))

for a in ans[::-1]:
    print(a)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int N;
int A[1000];


signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	int ma = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			ma = max(abs(A[i] - A[j]), ma);
		}
	}
	cout << ma << endl;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k,sum=0;
    cin>>n>>k;
    while(n){
        n/=k;
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;



int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end(), greater<int>());

    int alice = 0;
    int bob = 0;

    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0)
        {
            alice += A.at(i);
        }
        if ( i % 2 == 1)
        {
            bob += A.at(i);
        }
    }
    int ans = alice - bob;
    cout << ans << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void asspush(queue<string>&S,int N) {
	while (S.front().size() != N) {
		char maxc=0;
		for (size_t i = 0; i < S.front().size(); i++)
		{
			maxc = max(maxc, S.front().at(i));
		}
		for (size_t i = 'a'; i <= maxc+1; i++)
		{
			S.push(S.front() + char(i));
		}
		S.pop();
	}
}
int main() {
	int N;
	cin >> N;
	queue<string> S;
	S.push("a");
	vector<string>U;
	asspush(S, N);
	while (!S.empty()) {
		U.push_back((S.front()));
		S.pop();
	}
	sort(U.begin(), U.end());
	for (size_t i = 0; i < U.size(); i++)
	{
		cout << U.at(i)<<endl;
	}
}


Measured memory_bytes: 10744
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 1000 + 10;
const int MOD = 20071027;

int n;
int L[MAXN];

int main() {
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n * 2; ++i) {
            scanf("%d", &L[i]);
        }
        sort(L, L + 2 * n);
        int ans = 0;
        for (int i = 0; i < 2 * n; i += 2) {
            ans += min(L[i], L[i + 1]);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {

    private final int N;
    private final int M;
    private final int K;

    Solver(Scanner in){
        N = in.nextInt();
        M = in.nextInt();
        K = in.nextInt();
    }

    void solve() {
        for(int i = 0; i <= N; i++){
            for(int j = 0; j <= M; j++){
                if(i * M + j * N - 2 * i * j == K){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

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

int main(){
  int N;
  cin>>N;
  char c;
  bool flag=false;
  for(int i=0;i<N;i++){
    cin>>c;
    if(c=='Y') flag=true;
  }
  if(flag) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> costs(n);
  vector< vector<int> > a(n);
  rep(i, n) {
    cin >> costs[i];
    rep(j, m) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
  }

  vector<int> min_costs;
  for (int bit = 1; bit < (1 << n); bit++) {
    bool ok = true;
    int cost_sum = 0;
    vector<int> g(m);
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < m; j++) {
          g[j] += a[i][j];
        }
        //printf("debug: costs[%d] = %d\n", i, costs[i]);
        cost_sum += costs[i];
      }
    }
    for (auto v : g) if (v < x) ok = false;
    if (ok) min_costs.push_back(cost_sum);
  }

  if (min_costs.size() == 0) {
    cout << -1 << endl;
  } else {
    cout << *min_element(min_costs.begin(), min_costs.end()) << endl;;
  }

  return 0;
}


Measured memory_bytes: 3596
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
for (let i = 0; i < input.length; i++) {
    let [a, b] = input[i].split(' ').map(Number);
     if (a === 0 && b === 0) {
        break;
         }
    for (let j = 0; j < a; j++) {
        if (j === 0) {
           console.log('#'.repeat(b));
        }
        if (j === a - 2) {
           console.log('#'.repeat(b));
           break;
        }
        console.log('#' + '.'.repeat(b - 2) + '#');
    }
    console.log('');
}



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

int left = -1e6;
int right = 1e7;

int main() {
    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i <= x + k - 1; i++) {
        cout << i << ' ';
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int N, M, X;
	cin >> N >> M >> X;
	int A[110];
	rep(i, M) cin >> A[i];
	int cost1 = 0;
	int cost2 = 0;
	rep(i, M) {
		if (A[i]<X) cost1++;
		if (X<A[i] and A[i]<N) cost2++;
	}
	int ans = min(cost1, cost2);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
 
class Main {
	int n;
	HashSet<Integer> d;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		d = new HashSet<Integer>();
		for(int i=0;i<n;i++){
			d.add(sc.nextInt());
		}
	}
	void solve(){
		System.out.println(d.size());
	}
}

Measured memory_bytes: 25172
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    if(a + b < c * 2){
      System.out.println(a * x + b * y);
    }else{
      int sum = Math.min(x, y) * 2 * c;
      if(Math.max(x, y) == x){
        if(a > c * 2){
          sum += (x - y) * c * 2;
        }else{
          sum += (x - y) * a;
        }
      }else{
        if(b > c * 2){
          sum += (y - x) * c * 2;
        }else{
          sum += (y - x) * b;
        }
      }
      System.out.println(sum);
    }
  }
}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = -1;
    if (a % 2 || b % 2 || c % 2)
        ans = 0;
    if (ans == -1) 
        for (int i = 1; i <= 1e6; i++) {
            int x = (b + c) / 2, y = (a + c) / 2, z = (a + b) / 2;
            a = x;
            b = y;
            c = z;
            if (a % 2 || b % 2 || c % 2) {
                ans = i;
                break;
            }
        }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;
  Double ans = 0;
  for(Int i=0;i<N;i++) ans += ((Double)1.0)/(A[i]);
  ans = 1/ans;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256