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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

struct SCC {
    V<int> id;
    VV<int> groups;
};

template <class E> struct SCCExec : SCC {
    int n;
    const VV<E>& g;
    int tm = 0;
    V<bool> flag;
    V<int> low, ord, st;
    void dfs(int v) {
        low[v] = ord[v] = tm++;
        st.push_back(v);
        flag[v] = true;
        for (auto e : g[v]) {
            if (ord[e.to] == -1) {
                dfs(e.to);
                low[v] = min(low[v], low[e.to]);
            } else if (flag[e.to]) {
                low[v] = min(low[v], ord[e.to]);
            }
        }
        if (low[v] == ord[v]) {
            V<int> gr;
            while (true) {
                int u = st.back();
                st.pop_back();
                gr.push_back(u);
                if (u == v) break;
            }
            for (int x : gr) flag[x] = false;
            groups.push_back(gr);
        }
    }
    SCCExec(const VV<E>& _g)
            : n(int(_g.size())), g(_g), flag(n), low(n), ord(n, -1) {
        id = V<int>(n);
        for (int i = 0; i < n; i++) {
            if (ord[i] == -1) dfs(i);
        }
        reverse(groups.begin(), groups.end());
        for (int i = 0; i < int(groups.size()); i++) {
            for (int x : groups[i]) {
                id[x] = i;
            }
        }
    }
};


template <class E> SCC get_scc(const VV<E>& g) { return SCCExec<E>(g); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n, m;
    cin >> n >> m;
    struct E { int to; };
    VV<E> g(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back({b});
    }
    auto scc = get_scc(g);
    V<int> res(n, -1);
    for (int i = 0; i < n; i++) {
        for (auto e: g[i]) {
            int j = e.to;
            if (res[j] == -1 || scc.id[res[j]] < scc.id[i]) res[j] = i;
        }
    }

    for (int d: res) cout << d + 1 << endl;
    return 0;
}



Measured memory_bytes: 19056
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

   int N;
   cin >> N;
   int S1 = 0, S2 = 0;
   vector<int> W(N);
   for (int i = 0; i < N; ++i) {
      cin >> W[i];
      S2 += W[i];
   }

   for (int i = 0; i < N; ++i) {
      if (abs(S1 - S2) > abs(S1 - S2 + 2 * W[i])) {
         S1 += W[i];
         S2 -= W[i];
      }
      else
         break;
   }

   cout << abs(S1 - S2) << endl;

   return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int bubble_sort(int *a, int n){
    int count=0;
    for(int i = 0; i < n-1; i++){
        for(int j = n-1; j >= i+1; j--){
            if(a[j] < a[j-1]){
                int tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
                count++;
            }
        }
    }
    return count;
}
int main(){
    int n; scanf("%d", &n);
    int a[100];
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int b = bubble_sort(a, n);
    for(int i = 0; i < n-1; i++)
        printf("%d ", a[i]);
    printf("%d\n", a[n-1]);
    printf("%d\n", b);
}



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

string S;
int N;

void input() {
    cin >> N;
    cin >> S;
}

void solve() {
    input();
    string tmp = "No";
    int K = N / 2;
    if(N % 2 == 0 && S.substr(0, K) == S.substr(K, K)) tmp = "Yes";
    cout << tmp << endl;
    return;
}

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


Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 15
int cur;
string s;
int p[N];

bool parse();

bool i_parse() {
    char c = s[cur++];
    if(c == '-') {
        return !i_parse();
    }
    if(c == '(') {
        bool res = parse();
        cur++; // ')'
        return res;
    } else if(c == 'T' || c == 'F') {
        return (c == 'T');
    } else {
        return (p[c - 'a'] > 0);
    }
}

bool parse() {
    bool le = i_parse();
    char c = s[cur++];
    if(c == '-') cur++; // '>'
    bool ri = i_parse();
    switch(c) {
        case '*':
            return le && ri;
        case '+':
            return le || ri;
        case '-':
            return !le || ri;
    }
}

bool solve() {
    cur = 0;
    bool le = i_parse();
    cur ++; // '='
    bool ri = i_parse();
    return le == ri;
}

bool p_make(int c) {
    if(c == 11) {
        return solve();

    } else {
        rep(i, 2) {
            p[c] = i;
            if(!p_make(c+1)) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    while(cin >> s && s[0]!='#') {
        bool ans = p_make(0);
        cout << (ans ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1:
    a1[0] = max(a1[0],lst[0])
  elif lst[2] == 2:
    a2[0] = min(a2[0],lst[0])
  elif lst[2] == 3:
    a3[1] = max(a3[1],lst[1])
  elif lst[2] == 4:
    a4[1] = min(a4[1],lst[1])

print(max(0,a2[0]-a1[0])*max(0,a4[1]-a3[1]))


Measured memory_bytes: 3064
def freq_max(arr)
  str1, str2, count = "", "", 0
  
  arr.each do |word|
    tmp = arr.count(word)
    str1, count = word, tmp if count < tmp
    str2 = word if str2.length < word.length
  end
  
  return [str1, str2]
end

puts freq_max(gets.split).join(" ")

Measured memory_bytes: 6096
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999

int main() {
	int x, t;
	std::cin >> x >> t;
	if (x - t < 0) {
		std::cout << '0' << std::endl;
	}
	else {
		std::cout << x - t << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s;
    cin >> s;
    int a[60] = {};
    int k = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (a[s[i] - 'A'] == 0)
        {
            k++;
            a[s[i] - 'A']++;
        }
        else
            a[s[i] - 'A']++;
    }
    bool ans = true;
    if (k == 2)
    {
        for (int i = 0; i < 30; i++)
        {
            if (!(a[i] == 0 || a[i] == 2))
                ans = false;
        }
    }
    else
        ans = false;
    cout << (ans ? "Yes" : "No") << endl;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int num = 0; num < 1000; num++) {
        ostringstream sout;
        sout << setfill('0') << setw(3) << num;
        string m = sout.str();
        vector<bool> f(3, false);
        int idx = 0, i = 0;
        while (idx < n) {
            if (s[idx] == m[i]) {
                f[i] = true;
                i++;
            }
            idx++;
        }
        if (f[0] && f[1] && f[2]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    while (true){
        int H,W;
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i%2==0){
                    if(j%2==0){
                        cout << "#";
                    }
                    else{
                        cout <<".";
                    }
                }
                else{
                    if(j%2==0){
                        cout << ".";
                    }
                    else{
                        cout <<"#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3092
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::BinaryHeap;

fn main() {
    input!{
        n: usize,
        mut v: [usize; 1 << n]
    }
    let mut pq = BinaryHeap::new();
    pq.push(1 << n);
    v.sort_by(|x, y| y.cmp(x));
    let mut c = 1;
    let mut prev = v[0];
    for i in 1..1 << n {
        if prev == v[i] {
            c += 1;
        } else {
            let mut t = vec![];
            for _ in 0..c {
                if let Some(mut x) = pq.pop() {
                    x /= 2;
                    while x > 0 {
                        t.push(x);
                        x /= 2;
                    }
                } else {
                    println!("No");
                    return;
                }
            }
            for x in t {
                pq.push(x);
            }
            c = 1;
            prev = v[i];
        }
    }
    let mut t = vec![];
    for _ in 0..c {
        if let Some(mut x) = pq.pop() {
            x /= 2;
            while x > 0 {
                t.push(x);
                x /= 2;
            }
        } else {
            println!("No");
            return;
        }
    }
    for x in t {
        pq.push(x);
    }
    println!("Yes");
}


Measured memory_bytes: 6396
#include <iostream>
using namespace std;int day(int y,int m,int d){
    int i,i2,ans=0;
    for(i=1;i<y;i++){
        if(i%4==0&&(i%100!=0||i%400==0))ans+=366;
        else ans+=365;
    }
    for(i=1;i<m;i++){
        if(i==4||i==6||i==9||i==11)ans+=30;
        else if(i==2){
            if(y%4==0&&(y%100!=0||y%400==0))ans+=29;
            else ans+=28;
        }
        else ans+=31;
    }
    ans+=d;
    return ans;
}
int main(void){
    int y1,y2,m1,m2,d1,d2;
    cin>>y1>>m1>>d1>>y2>>m2>>d2;
    while(y1!=-1){
        cout<<(day(y1,m1,d1)-day(y2,m2,d2))*-1<<endl;
        cin>>y1>>m1>>d1>>y2>>m2>>d2;
    }
}

Measured memory_bytes: 2976
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

graph=[set() for _ in range(N+1)]
for _ in range(M):
  A,B=map(int,input().split())
  graph[A].add(B)
#print(graph)

visited=[False]*(N+1)
def dfs(path):
  global cycle
  u=path[-1]
  
  visited[u]=True  
  for v in graph[u]:
    if visited[v]:
      cycle=list(path+[v])
      return
    else:
      dfs(path+[v])      
    if cycle:
      return    
  visited[u]=False
  
cycle=[]
for i in range(1,N+1):
  dfs([i])
  if cycle:
    break
else:
  print(-1)
  sys.exit(0)
    
#remove prefix  
for i in range(len(cycle)):
  if cycle[i]==cycle[-1]:
    cycle=cycle[i:]
    break
#print(cycle)

cycle_set=set(cycle)
subgraph=[set() for _ in range(N+1)]
for c in cycle_set:
  for v in graph[c]:
    if v in cycle_set:
      subgraph[c].add(v)
#print(subgraph)    

#visited=[False]*(N+1)
ex_path=[]
def dfs2(path,t):
  global ex_path
  u=path[-1]
  if u==t:
    ex_path=path
    return
  
  for v in graph[u]:
    dfs2(path+[v],t)
    if ex_path:
      return

graph=subgraph
while True:
  for i in range(len(cycle)-1):
    u=cycle[i]
    v=cycle[i+1]
    w=-1
    if len(graph[u])>1:
      for x in graph[u]:
        if x!=v:
          w=x
          break
      break
  else:
    print(len(cycle)-1)
    for i in range(len(cycle)-1):
      print(cycle[i])
    sys.exit(0)
    
  #print(u,v,w)
  #w->u
  dfs2([w],u)
  cycle=ex_path+[w]
  #print(cycle)
  cycle_set=set(cycle)
  subgraph=[set() for _ in range(N+1)]
  for c in cycle_set:
    for v in graph[c]:
      if v in cycle_set:
        subgraph[c].add(v)
        
  graph=subgraph

Measured memory_bytes: 8052
#include<stdio.h>
#include<string.h>
int main()
{
	int a=0,b=0,c=0,d=0;
	scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
	if(a!=b&&b!=c&&c!=d)
	printf("Good\n");
	else
	printf("Bad\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if ((B - A - 1) % 2 == 0) {
		cout << "Borys";
	}
	else {
		cout << "Alice";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//文字列S
		String S = sc.next();
		//int S = sc.nextInt();

		//すべて'x'に変換する
		S = S.replaceAll(".", "x");

		System.out.println(S);
	}

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

ll N,M,R;
Vector r;
DVector mp;
ll ct = INF;
void dfs(Vector a){
  if(a.size() == R){
    ll cost = 0;
    rep(i,R-1)cost += mp[a[i]][a[i+1]];
    minch(ct, cost);
  }else{
    each(itr,r){
      if(exist(a, itr))continue;
      Vector ta = a;
      ta.pb(itr);
      dfs(ta);
    }
  }
}

int main(){
  cin.sync_with_stdio(false);
  cin >> N >> M >> R;
  r.resize(R);
  mp.resize(N, Vector(N,INF));
  rep(i,R){
    cin >> r[i];
    r[i]--;
  }
  rep(i,M){
    ll a, b, c;
    cin >> a >> b >> c;
    mp[a-1][b-1] = c;
    mp[b-1][a-1] = c;
  }
  rep(k,N)rep(i,N)rep(j,N)minch(mp[i][j], mp[i][k]+mp[k][j]);
  dfs(Vector());
  cout << ct << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<pair<string,lint>> vec;
  for(int i=0;i<n;i++){
    pair<string,lint> tmp;
    cin>>tmp.first>>tmp.second;
    vec.push_back(tmp);
  }
  string s;
  cin>>s;
  bool found=false;
  lint result=0;
  for(int j = 0; j < n; ++j){
    if(found){
      result+=vec[j].second;
    }else{
      if(s==vec[j].first){
        found=true;
      }
    }
  }

  cout<<result<<endl;



  return 0;
}




Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();

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

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

namespace _065
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(n=>int.Parse(n)).ToArray();
            var x = line[0];
            var a = line[1];
            var b = line[2];

            if(a >= b)
            {
                Console.WriteLine("delicious");
            }
            else if(x >= b - a)
            {
                Console.WriteLine("safe");                
            }
            else
            {
                Console.WriteLine("dangerous");
            }            
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int a,b;
  char c;
  cin >> a >> c >> b;
  if(c=='+')cout << a+b << endl;
  else if(c=='-')cout << a-b << endl;
}

Measured memory_bytes: 3628
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int main() {
	LL n; cin >> n;
	cout << n * n * n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;

    ll ans = 1;

    if(n == 1){
        cout << 3 << endl;
        return 0;
    }


    int jud;
    int see = 1;

    if(s1[0] != s1[1]){
        jud = 1;
        ans = 3;
    }

    else{
        jud = 2;
        ans = 6;
        see++;
    }

    for(int s = see; s< n-1; s++){

        if(jud == 1){
            if(s1[s] != s1[s+1]){
                ans *= 2;
            }
            else{
                ans *= 2;
                jud = 2;
                s++;
            }
            ans %= 1000000007;
            continue;
        }
        
        if(jud == 2){
            if(s1[s] != s1[s+1]){
                ans *= 1;
                jud = 1;
            }
            else{
                ans *=3;
                s++;
            }
            ans %= 1000000007;
            continue;
        }
    }

    if(jud == 1 && s1[n-1] != s1[n-2] && s1[n-2] != s1[n-3] && n>=3){
        ans *= 2;
        ans %= 1000000007;
    }

    if((n == 2) && jud == 1 && s1[n-1] != s1[n-2]) ans*=2;

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	distance, _ := strconv.ParseFloat(scanner.Text(), 64)

	scanner.Scan()
	time, _ := strconv.ParseFloat(scanner.Text(), 64)

	scanner.Scan()
	speed, _ := strconv.ParseFloat(scanner.Text(), 64)

	if distance/speed > time {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1776
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i,a,n) for(int i=a;i<n;i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrepa(i,a,n) for (int i = n; i >= a; i--)
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    int n,k;
    cin>>n>>k;
    vi v (n);
    rep(i,n)
        cin>>v[i];
    sort(all(v));
    ll total=0;
    for(int i=0;i<k;i++)
        total+=v[i];
cout<<total<<endl;
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n,k,x,y;
	cin>>n>>k>>x>>y;

	int res=0;
	for(int i=0;i<n;i++){
		if(i<k) res+=x;
		else res+=y;
	}

	cout<<res<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int w,h,n;
int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};
string mp[20];

struct dat{
  int y1,x1;
  int y2,x2;
  int y3,x3;
};


int D[14][14][15][14][14][15];
queue<dat> Q;
void DD(dat &a,int b){D[a.y1-1][a.x1-1][a.y2-1][a.x2-1][a.y3-1][a.x3-1] = b;}
int DD(const dat &a){return D[a.y1-1][a.x1-1][a.y2-1][a.x2-1][a.y3-1][a.x3-1];}

bool check(const dat &a){
  if(mp[a.y1][a.x1]=='#') return 0;
  if(n>=2&&mp[a.y2][a.x2]=='#') return 0;
  if(n>=3&&mp[a.y3][a.x3]=='#') return 0;
  return DD(a)==-1;
}

void update(const dat &a){
  int cost = DD(a);

  for(int i=0;i<5;i++){
    int ny1 = a.y1+dy[i], nx1 = a.x1+dx[i];
    for(int j=0;j<5;j++){
      int ny2 = a.y2+dy[j], nx2 = a.x2+dx[j];
      if(n<=1) ny2 = 15,nx2 = 14;
      for(int k=0;k<5;k++){
	int ny3 = a.y3+dy[k], nx3 = a.x3+dx[k];
	if(n<=2) ny3 = 14,nx3 = 15;

	dat nt = (dat){ny1,nx1,ny2,nx2,ny3,nx3};
	if(!check(nt))continue;
	
	if((ny1==ny2&&nx1==nx2) ||(ny2==ny3&&nx2==nx3) ||(ny3==ny1&&nx3==nx1))continue;//same pos
	if(((a.y1==ny2&&a.x1==nx2) && (a.y2==ny1&&a.x2==nx1)) || // swap positoin
	   ((a.y2==ny3&&a.x2==nx3) && (a.y3==ny2&&a.x3==nx2)) ||
	   ((a.y3==ny1&&a.x3==nx1) && (a.y1==ny3&&a.x1==nx3)) )continue;
	
	Q.push(nt);
	DD(nt,cost+1);
      }
    }
  }
}

bool goal(const dat &s,const dat &t){
  char &a = mp[s.y1][s.x1];
  char &b = mp[s.y2][s.x2];
  char &c = mp[s.y3][s.x3];
  char &A = mp[t.y1][t.x1];
  char &B = mp[t.y2][t.x2];
  char &C = mp[t.y3][t.x3];
  return toupper(a)==A&&(n<=1||toupper(b)==B)&&(n<=2||toupper(c)==C);
}

int bfs(dat &start){
  memset(D,-1,sizeof(D));
  while(!Q.empty())Q.pop();
  Q.push(start);
  DD(start,0);
  
  while(!Q.empty()){
    dat t = Q.front();Q.pop();
    if(goal(start,t)) return DD(t);
    update(t);
  }
  return 0;
}

int main(){
  while(1){
  cin>>w>>h>>n;
  if(!w&&!h&&!n)break;
  cin.ignore();
  for(int i=0;i<h;i++)getline(cin,mp[i]),mp[i]+='#';
  
  dat start = (dat){15,15,15,14,14,15};
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(!islower(mp[i][j]))continue;
      if(start.y1==15) start.y1=i,start.x1=j;
      else if(start.y2==15) start.y2=i,start.x2=j;
      else start.y3=i,start.x3=j;
    }
  cout<<bfs(start)<<endl;
  }
  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= 9; i++)
  {
    int buf = n;
    if (buf % i == 0)
    {
      if (buf / i >= 1 && buf / i <= 9)
      {
        ans = 1;
      }
    }
  }
  if (ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3580
import sys
n = int(input())
ns = [int(input()) for _ in range(n)]
if not 2 in ns:
    print(-1)
    sys.exit(0)
i = 0
cnt = 0
pushed = [0]*n
flg = False
while(True):
    cnt += 1
    i = ns[i] - 1
    if pushed[i] == 1:
        break
    pushed[i] = 1
    if i == 1:
        flg = True
        break
if flg:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 7976
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s[8];
int ng[8][8];
bool flg;
int used[8] = {0};
void dfs(int r){
  if(r==8){
    flg=1;
    return;
  }
  for(int c=0;c<8;c++){
    if(s[r][c]=='Q'){
      dfs(r+1);
      return;
    }
  }
  for(int c=0;c<8;c++){
    if(!used[c]) {
      if(ng[r][c]) continue;
      s[r][c]='Q';
      for(int j=0;j<8;j++){
        // if(r+j<8 ) ng[r+j][c]++;
        // if(r-j>=0) ng[r-j][c]++;
        // if(c+j<8 ) ng[r][c+j]++;
        // if(c-j>=0) ng[r][c-j]++;
        if(r+j<8 &&c+j<8 ) ng[r+j][c+j]++;
        if(r-j>=0&&c+j<8 ) ng[r-j][c+j]++;
        if(r-j>=0&&c-j>=0) ng[r-j][c-j]++;
        if(r+j<8 &&c-j>=0) ng[r+j][c-j]++;
      }
      used[c] = 1;
      dfs(r+1);
      if(flg) return;
      used[c] = 0;
      s[r][c]='.';
      for(int j=0;j<8;j++){
        // if(r+j<8 ) ng[r+j][c]--;
        // if(r-j>=0) ng[r-j][c]--;
        // if(c+j<8 ) ng[r][c+j]--;
        // if(c-j>=0) ng[r][c-j]--;
        if(r+j<8 &&c+j<8 ) ng[r+j][c+j]--;
        if(r-j>=0&&c+j<8 ) ng[r-j][c+j]--;
        if(r-j>=0&&c-j>=0) ng[r-j][c-j]--;
        if(r+j<8 &&c-j>=0) ng[r+j][c-j]--;
      }
    }
  }
}
signed main(){
  for(int i=0;i<8;i++) s[i]=string(8,'.');
  int n;
  cin>>n;
  memset(ng,0,sizeof(ng));
  for(int i=0;i<n;i++){
    int r,c;
    cin>>r>>c;
    s[r][c]='Q';
    used[c]=1;
    for(int j=0;j<8;j++){
      // if(r+j<8 ) ng[r+j][c]++;
      // if(r-j>=0) ng[r-j][c]++;
      // if(c+j<8 ) ng[r][c+j]++;
      // if(c-j>=0) ng[r][c-j]++;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]++;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]++;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]++;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]++;
    }
  }
  flg=0;
  dfs(0);
  for(int i=0;i<8;i++) cout<<s[i]<<endl;
  return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    bool flag = true;
    for(int i = 0; i < s.size(); i += 2){
        if(s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D'){
            
        }else{
            flag = false;
        }
    }
    for(int i = 1; i < s.size(); i += 2){
        if(s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D'){
            
        }else{
            flag = false;
        }
    }
    if(flag == true){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
from collections import deque
que = deque()
l = input()
S = 0
S2 = []
for j in range(len(l)):
    i = l[j]
    if i == '\\':
        que.append(j)
        continue
    elif i == '/':
        if len(que) == 0:
            continue
        k = que.pop()
        pond_sum = j-k
        S += pond_sum
        while S2 and S2[-1][0] > k:
            pond_sum += S2[-1][1]
            S2.pop()
        S2.append([k,pond_sum])
    elif i == '_':
        continue
data = [i for j,i in S2]
print(S)
print(len(S2),*data)


Measured memory_bytes: 6784
/*総当たり*/
#include <stdio.h>
#define N 2000

int solve(int, int);
int a[N], n;

int main(){
  int q, i, j;
  int m[N];

  /*値の入力*/
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &m[i]);
  }
  
  for(i=0; i<q; i++){
    if ( solve(0, m[i]) )
      printf("yes\n");
    else{
      printf("no\n");
    }
  }
  
  return 0;
}

int solve(int i, int m){
  int res;
  if (m == 0) return 1;

  if (i >= n) return 0;

  res = solve(i+1, m) || solve(i+1, m - a[i]);
  return res;
}



Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    int a,b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;

}

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

int a,b,c[4005][4005],ans=1;
int C(int x,int y){
	if(x<0||y>x)return 0;
	return c[x][y];
}
int main(){
	scanf("%d%d",&a,&b);
	for(int i=0;i<=a+b;i++){
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%M;
	}
	ans=a+1;
//	for(int i=1;i<=b;i++)ans=(ans+1ll*C((i<b?a-b+i+1:a-b+i),1)*C(b-1,i-1))%M;
	for(int i=1;i<b;i++)for(int j=1;j+i<=b;j++){
		int t=C(a-b*2+i*2+j+2,2);
		ans=(ans+1ll*C(b-1,i-1)*C(b-1-i,j-1)%M*t)%M;
 	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 61312
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n; cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];
    int s1 = 0, s2 = 0;
    int dif_min = 1000000;
    rep(i, n) s2 += w[i];
    rep(i, n){
        s1 += w[i];
        s2 -= w[i];
        dif_min = min(abs(s2 - s1), dif_min);
    }
    cout << dif_min << endl;
}

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define maxarr(A,n) *max_element(A,A+n) 
#define minarr(A,n) *min_element(A,A+n);
#define ft first
#define sd second
#define all(v) (v.begin(),v.end())
#define vll vector<ll> 
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pb push_back
#define show(x) cout<<#x<<" "<<x<<endl;

void solve()
{
	string s;
	ll k;
	cin>>k;
	cin>>s;
	if(s.length()<=k)
		cout<<s<<endl;
	else
	{

		for(ll i=0;i<k;i++)
			cout<<s[i];
		cout<<"..."<<endl;
	}
}

int main()
{
	fastio();

	ll T=1;	//cin>>T;
	while(T--) solve();
	
	//check_time();
	return 0;   
}   



Measured memory_bytes: 3648
N = int(input())
A = []
for i in range(1, N+1):
    for j in range(i+1, N+1):
        A.append([i, j])
M = len(A)
B = []
if N%2 == 1:
    for a in A:
        if sum(a) != N:
            B.append(a)
else:
    for a in A:
        if sum(a) != N+1:
            B.append(a)
print(len(B))
for b in B:
    print(' '.join(map(str, b)))

Measured memory_bytes: 3848
def main():
    S = input()
    from itertools import groupby
    ans = 0
    g = [(k, len(list(v))) for k, v in groupby(S)]
    p = 0
    m = 0
    if g[0][0] == '>':
        ans += g[0][1]*(g[0][1]+1)//2
        p += 1
    if g[-1][0] == '<':
        ans += g[-1][1]*(g[-1][1]+1)//2
        m += 1
    for i in range(p, len(g)-m, 2):
        if g[i][1] > g[i+1][1]:
            m = g[i+1][1]
            n = g[i][1]
        else:
            n = g[i+1][1]
            m = g[i][1]
        ans += (m-1)*m//2
        ans += n*(n+1)//2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81608
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll x;cin>>x;
    rep(i,-1000,1001){
        rep(j,-1000,1001){
            ll u=Pow(i,5)-Pow(j,5);
            if(u==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

const LLI INF = 1LL<<50;

LLI dp[1<<12];
bool visited[1<<12];

int N,M;
vector<LLI> A;
vector<int> C;


LLI rec(int s){
  if(s == 0) return dp[s] = 0;
  
  if(visited[s]) return dp[s];
  visited[s] = true;


  REP(i,M){
    int t = s ^ (s & C[i]);
    
    chmin(dp[s], rec(t)+A[i]);
  }
  

  return dp[s];
}



int main(){
  while(cin >> N >> M){
    A = vector<LLI>(M);
    C = vector<int>(M);

    REP(i,M){
      cin >> A[i];
      int b; cin >> b;
      REP(j,b){
        int x; cin >> x;
        --x;
        C[i] |= bit(x);
      }
    }

    //dump(C);

    fill_array(dp, INF);
    fill_array(visited, false);

    int t = (1<<N)-1;
    rec(t);

    if(dp[t] == INF){
      cout << -1 << endl;
    }else{
      cout << dp[t] << endl;
    }
  }


  return 0;
}


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

int		main()
{
	char	A[11];
	char	B[11];
	char	U[11];
	int		a, b;
	int		r;


	r = scanf("%s %s\n", A, B);
	r = scanf("%d %d\n", &a, &b);
	r = scanf("%s\n", U);
	if (!r)
		return (0);
	if (strcmp(A, U))
		b--;
	else
		a--;
	printf("%d %d\n", a, b);
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void solve(long long N, std::vector<long long> A){
    map<LL,LL> list;
    SORT(A);
    reverse(A.begin(), A.end());
    REP(i, N){
        list[A[i]]=0;
    }
    REP(i, N){
        list[A[i]]++;
    }
    // sort(list.begin(), list.end(), compare_by_b);
    LL sq=0;
    REP(i, A.size()){
        if(list[A[i]]>=(LL)4)sq = max(sq, A[i]*A[i]);
    }
    LL rec=0;
    LL first=0, second=0;
    // bool first_found=false;
    REP(i, A.size()){
        if(list[A[i]]>=2)first=max(first,A[i]);
    }
    REP(i, A.size()){
        if(list[A[i]]>=2 && A[i]<first)second=max(second,A[i]);
    }
    rec = first*second;
    cout<<max(rec,sq)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 7296