akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;

struct edge {
	int to, cap, rev, ID;
	bool is_rev;
	edge(int t, int c, int r, int id, bool i):to(t), cap(c), rev(r), ID(id), is_rev(i){}
};

constexpr int INF = (1 << 29);
vector<vector<edge>> G;
vector<int> level;
vector<int> iter;

void init(int V) {
	G.assign(V, vector<edge>());
	level.resize(V);
	iter.resize(V);
}

void add_edge(int from, int to, int ID) {
	G[from].emplace_back(to, 1, G[to].size(), ID, false);
	G[to].emplace_back(from, 1, G[from].size() - 1, ID, true);
}

void bfs(int s) {
	fill(level.begin(), level.end(), -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		for(const auto &e : G[v]) {
			if(e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f) {
	if(v == t) return f;
	for(int &i = iter[v]; i < static_cast<int>(G[v].size()); ++i) {
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]) {
			const int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	while(true) {
		bfs(s);
		if(level[t] < 0) return flow;
		fill(iter.begin(), iter.end(), 0);
		for(int f; (f = dfs(s, t, INF)) > 0; flow += f) ;
	}
}

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

	int n, m;
	cin >> n >> m;

	init(n);
	for(int i = 1; i <= m; ++i) {
		int from, to;
		cin >> from >> to;
		--from; --to;
		add_edge(from, to, i);
	}

	int S, T;
	cin >> S >> T;
	const int ans = max_flow(S - 1, T - 1);

	set<int> reverse_edges;
	for(const auto &edges : G) {
		for(const auto &e : edges) {
			if(e.cap == 0 && e.is_rev) reverse_edges.insert(e.ID);
		}
	}

	cout << ans << endl;
	cout << reverse_edges.size() << endl;
	for(const auto &ID : reverse_edges) {
		cout << ID << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1296
#include <iostream>
#include <vector>
using namespace std;
struct Tree{
	int parent, left, right;
	int degree;
	int depth;
	int height;
	int sibling;
	vector<int> child;
};
void getDepth(int i, Tree T[]){
	if(T[i].degree!=0){
		for(int j=0; j<T[i].degree; j++){
			T[T[i].child[j]].depth=T[i].depth+1;
			getDepth(T[i].child[j], T);
		}
	}
}
void getHeight(int i, Tree T[]){
	if(T[i].degree==0)
		T[i].height=0;
	if(T[i].parent!=-1){
		T[T[i].parent].height=max(T[T[i].parent].height, T[i].height+1);
		getHeight(T[i].parent, T);
	}
}
int main(){
	int n;
	cin>>n;
	Tree T[n];
	for(int i=0; i<n; i++){
		T[i].parent=-1;
		T[i].sibling=-1;
		T[i].degree=0;
		T[i].depth=0;
		T[i].height=0;
	}
	for(int i=0; i<n; i++){
		int node, l, r;
		cin>>node>>l>>r;
		T[node].left=l;
		T[node].right=r;
		if(l!=-1){
			T[l].parent=node;
			T[node].degree++;
			T[node].child.push_back(l);
			if(r!=-1)
				T[l].sibling=r;
		}
		if(r!=-1){
			T[r].parent=node;
			T[node].degree++;
			T[node].child.push_back(r);
			if(l!=-1)
				T[r].sibling=l;
		}
	}
	int p;
	for(p=0; p<n; p++){
		if(T[p].parent==-1){
			//p=i;
			break;
		}
	}
	getDepth(p, T);
	for(int i=0; i<n; i++){
		if(T[i].degree==0)
			getHeight(i, T);
	}
	for(int i=0; i<n; i++){
		cout<<"node "<<i<<": "<<"parent = "<<T[i].parent<<", sibling = "<<T[i].sibling<<", degree = "<<T[i].degree<<", depth = "<<T[i].depth<<", height = "<<T[i].height<<", ";
		if(T[i].parent==-1)
			cout<<"root"<<endl;
		else{
			if(T[i].degree==0)
				cout<<"leaf"<<endl;
			else
				cout<<"internal node"<<endl;
		}
	}
}


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

int main() {
    long long int N, M;
    while (cin >> N >> M, N || M) {
        int count = 0;
        if (M > N) {
            int tmp = N;
            N = M;
            M = tmp;
        }
        while (M) {
            long long int tmp = N % M;
            N = M;
            M = tmp;
            count++;
        }

        cout << N << " " << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
double a;
while(cin>>a){
if(a<=48)cout<<"light fly";
else if(a<=51)cout<<"fly";
else if(a<=54)cout<<"bantam";
else if(a<=57)cout<<"feather";
else if(a<=60)cout<<"light";
else if(a<=64)cout<<"light welter";
else if(a<=69)cout<<"welter";
else if(a<=75)cout<<"light middle";
else if(a<=81)cout<<"middle";
else if(a<=91)cout<<"light heavy";
else cout<<"heavy";
cout<<endl;
}
return 0;
}

Measured memory_bytes: 1224
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {+0,+1,+0,-1};
const static int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-12;

int W,H;
char stage[1001][1001];
bool visited[1001][1001];

class State{
public:
  int x;
  int y;
  int cost;
  State(int _x,int _y,int _c) : x(_x),y(_y),cost(_c){}

  bool operator <(const State& s) const{
    return cost < s.cost;
  }
  bool operator >(const State& s) const{
    return cost > s.cost;
  }
};

void bfs(){
  priority_queue<State,vector<State>,greater<State> > que;
  que.push(State(0,0,0));
  
  while(!que.empty()){
    State s = que.top();
    que.pop();
    int sx = s.x;
    int sy = s.y;
    if(visited[sy][sx]) continue;

    visited[sy][sx] = true;
    if(stage[sy][sx] == 't') break;
    for(int i=0;i<4;i++){
      int dx = sx + tx[i];
      int dy = sy + ty[i];
      if(dx < 0 || dy < 0 || dx >= W || dy >= H) continue;
      if(visited[dy][dx]) continue;
      if(stage[dy][dx] == '#') continue;
      que.push(State(dx,dy,s.cost+1));
    }
  }
}

void dfs(int sx,int sy){
  visited[sy][sx] = true;
  for(int i=0;i<4;i++){
    int dx = sx + tx[i];
    int dy = sy + ty[i];
    if(dx < 0 || dy < 0 || dx >= W || dy >= H) continue;
    if(visited[dy][dx]) continue;
    if(stage[dy][dx] == '#') continue;
    dfs(dx,dy);
  }
}

bool has_route(int time,const vector<P>& gates,
	       int gx,int gy){

  vector<P> skip;
  for(int i=0;i<time;i++){
    int x = gates[i].first;
    int y = gates[i].second;
    if(stage[y][x] == '.'){
      skip.push_back(gates[i]);
    }
    stage[y][x] = '.';
  }
  memset(visited,false,sizeof(visited));
  bfs();

  for(int i=0;i<time;i++){
    int x = gates[i].first;
    int y = gates[i].second;
    stage[y][x] = '#';
  }

  for(int i=0;i<skip.size();i++){
    int x = skip[i].first;
    int y = skip[i].second;
    stage[y][x] = '.';
  }
  return visited[gy][gx];
}

int main(){

  while(~scanf("%d %d",&W,&H)){

    int gx,gy;
    for(int y=0;y<H;y++){
      string line;
      cin >> line;
      for(int x=0;x<W;x++){
	stage[y][x] = line[x];
	if(line[x] == 't'){
	  gx = x;
	  gy = y;
	}
      }
    }

    vector<P> gates;
    int total_time;
    scanf("%d",&total_time);
    for(int time=0;time<total_time;time++){
      int x,y;
      scanf("%d %d",&x,&y);
      gates.push_back(P(x,y));
    }

    int min_time = 0;
    int max_time = gates.size();
    bool isok = false;
    for(int round=0;round<10;round++){
      int mid = (min_time + max_time) / 2;
      if(has_route(mid,gates,gx,gy)){
	max_time = mid;
	isok = true;
      }
      else{
	min_time = mid+1;
      }
    }

    printf("%d\n",isok ? max_time : -1);
  }
}

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

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

int main(){
    string s;
    cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}  

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

bool ask(int64_t n)
{
    cout << "? " << n << endl
         << flush;

#if 0
    int ans = 10;
    string sn = to_string(n);
    string sa = to_string(ans);
    return (n <= ans && sn <= sa) || (n > ans && sn > sa);
#endif

    string rep;
    cin >> rep;
    return rep == "Y";
}

int main()
{
    cin.tie(0);

    int keta = 1;
    {
        int64_t mi = 1, ma = 9;

        int fst = -1, lst = -1;

        for (int i = 1; i <= 10; i++) {
            bool bmi = ask(mi);
            bool bma = ask(ma);

            if (bmi && bma) {
                if (fst == -1) {
                    fst = i;
                }
                lst = i;
            }

            mi = mi * 10;
            ma = ma * 10 + 9;
        }

        if (fst == 1) {
            if (lst == 10) {
                keta = fst;
            } else {
                keta = lst;
            }
        } else {
            keta = fst;
        }
    }

    int64_t lo = 1, hi = 10;
    for (int i = 1; i < keta; i++) {
        lo *= 10;
        hi *= 10;
    }

    while (hi - lo > 1) {
        int64_t mi = (lo + hi) / 2;

        if (!ask(mi * 10)) {
            lo = mi;
        } else {
            hi = mi;
        }
    }

    cout << "! " << (ask(lo * 10) ? lo : lo + 1) << endl
         << flush;

    return 0;
}


Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
int main() {
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		a[x]++;
		a[y]++;
	}
	bool ch=true;
	for(ll i=0;i<n;i++){
		if(a[i]%2!=0){
			ch=false;
		}
	}
	cout << (ch?"YES":"NO");
	// your code goes here
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

ll N, K;

ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}

ll f(ll x){
  return mpow(K/x, N);
}

int main(){
  cin >> N >> K;
  vector<ll> gcds(100010, 0);
  ll ans = 0;
  for(ll i=K; i>0; i--){
    ll now = i;
    ll cnt = f(now)%mod;
    while(1){
      now += i;
      if(now > K) break;
      cnt -= gcds[now];
      cnt += mod;
      cnt %= mod;
    }
    gcds[i] = cnt;
    ans += (cnt*i)%mod;
    //cout << ans << endl;
  }
  cout << ans%mod << endl;
  return 0;
}


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

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

    vector<pair<int, int>> arr(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        arr[i] = {a, b};
    }

    sort(arr.begin(), arr.end());
    priority_queue<int> pq;
    int ans = 0, pos = 0;

    for (int i = 1; i <= m; i++) {
        while (pos < n && arr[pos].first <= i) {
            auto t = arr[pos];
            pq.push(t.second);
            pos++;
        }
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

    cout << ans << endl;
}

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0; i<N; i++){
    cin >> L[i];
  }
  int d=0;
  int count;
  for(int i=1; i<=N; i++){
    d = d+L[i-1];
    if(d>X){count=i;break;}
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000)

n = int(input())
A = [int(input()) for i in range(n)] * 3
dp = [[-1 for i in range(n * 2)] for j in range(n * 2)]

def dfs(i,j):
  #if (j - i > n - 1):undefined
  if dp[i][j] != -1:
    pass
  elif (j - i == n - 1):
    dp[i][j] = 0
  elif (j - i) % 2 == 0:
    if A[i - 1] > A[j + 1]:
      dp[i][j] = dfs(i - 1, j)
    else:
      dp[i][j] = dfs(i, j + 1)
  else:
    dp[i][j] = max(dfs(i - 1, j) + A[i - 1], dfs(i, j + 1) + A[j + 1])
  return dp[i][j]
ans = 0
for i in range(n):
  ans = max(ans, dfs(i,i) + A[i])
print(ans)


Measured memory_bytes: 226448
def check(N, A, n):
    for i in range(min(n, N)+1):
        x = n - i
        cnt = 0
        for a in A:
            if a + x >= N:
                cnt += -(-(a + x - N + 1)//(N+1))
        if cnt <= x:
            return True
    return False


def main():
    N = int(input())
    A = list(map(int, input().split()))
    lo = 0
    hi = int(1e18)
    while lo < hi:
        mid = (lo + hi) // 2
        if check(N, A, mid):
            hi = mid
        else:
            lo = mid + 1
    print(lo)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39536
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> a;
  vector<int> b;
  vector<int> c;
  REP(i,n){
    int tmp;
    cin >> tmp;
    if(tmp==1) a.push_back(i);
  }
  int len=0;
  REP(i,m){
    int tmp;
    cin >> tmp;
    REP(j,tmp){
      if(i%2) b.push_back(len+j);
      else c.push_back(len+j);
    }
    len+=tmp;
  }
  int answer=1024;
  if(a.size()==b.size()){
    int pena=0;
    REP(i,a.size()) pena+=abs(a[i]-b[i]);
    answer=min(answer,pena);
  }
  if(a.size()==c.size()){
    int pena=0;
    REP(i,a.size()) pena+=abs(a[i]-c[i]);
    answer=min(answer,pena);
  }
  cout << answer << endl;
  return 0;

}

Measured memory_bytes: 3168
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main(int argv, char** argc) { int N;
  int ans=0;
  cin >> N;
  int B[N-1];	
  cin >> B[0];
  ans += B[0];
  for(int i=1;i<N-1;i++){
    cin >> B[i];
    ans+=min(B[i-1],B[i]);
  }
  ans+=B[N-2];
  cout << ans << endl;

  return 0;

}


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

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

    string A(to_string(a)),B(to_string(b));
    for (int i = 1; i < b; i++)
    {
        A+=to_string(a);
    }
    for (int i = 1; i < a; i++)
    {
        B+=to_string(b);
    }
    vector<string>ans={A,B};
    sort(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	// 配列版
	public static boolean nextPermutation(int[] a) {
		for (int i = a.length - 1; i > 0; --i) {
			if (a[i - 1] < a[i]) {
				int swapIndex = find(a[i - 1], a, i, a.length - 1);
				int temp = a[swapIndex];
				a[swapIndex] = a[i - 1];
				a[i - 1] = temp;
				Arrays.sort(a, i, a.length);
				return true;
			}
		}
		return false;
	}

	// destより大きい要素の中で最小のもののインデックスを二分探索で探す
	private static int find(int dest, int[] a, int s, int e) {
		if (s == e) {
			return s;
		}
		int m = (s + e + 1) / 2;
		return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
	}

	// List版
	public static <T extends Comparable<? super T>> boolean nextPermutation(
			List<T> l) {
		int size = l.size();
		for (int i = size - 1; i > 0; --i) {
			if (l.get(i - 1).compareTo(l.get(i)) < 0) {
				int swapIndex = find(l.get(i - 1), l, i, size - 1);
				Collections.swap(l, i - 1, swapIndex);
				Collections.sort(l.subList(i, size));
				return true;
			}
		}
		return false;
	}

	private static <T extends Comparable<? super T>> int find(T dest,
			List<T> a, int s, int e) {
		if (s == e) {
			return s;
		}
		int m = (s + e + 1) / 2;
		return a.get(m).compareTo(dest) <= 0 ? find(dest, a, s, m - 1)
				: find(dest, a, m, e);
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();

		String[] p = new String[n];
		String[] q = new String[n];

		for (int i = 0; i < n; i++) {
			p[i] = stdIn.next();
		}
		for (int i = 0; i < n; i++) {
			q[i] = stdIn.next();
		}

		String pp = "";
		String qq = "";
		String[] count = new String[n];

		for (int i = 0; i < n; i++) {
			pp += p[i];
			qq += q[i];
			count[i] = String.valueOf(i + 1);
		}

		int[] tmp = new int[count.length];

		for (int i = 0; i < n; i++) {
			tmp[i] = Integer.parseInt(count[i]);
		}

		int a = 0;
		int b = 0;

		int index = 0;

		int ppp = Integer.parseInt(pp);
		int qqq = Integer.parseInt(qq);

		do {
			String s = "";
			for (int i = 0; i < n; i++) {
				s += String.valueOf(tmp[i]);
			}
			int ss = Integer.parseInt(s);

			if (ppp == ss && qqq == ss) {
				a = index;
				b = index;
				index++;
			} else if (ppp == ss) {
				a = index;
				index++;
			} else if (qqq == ss) {
				b = index;
				index++;
			} else {
				index++;
			}
		} while (nextPermutation(tmp));

		System.out.println(Math.abs(a - b));

	}

}


Measured memory_bytes: 48752
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;


int main(int argc, const char * argv[]) {
  double n;
  cin >> n;
  double nar = 99999999999999999;
  double a;
  for(int i = 0; i < 5; i++){
    cin >> a;
    nar = min(nar, a);
  }
  long long int ans = ceil(n/nar) + 4;

  printf("%lld\n" , ans);
  return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int x = stoi(s+t);
    for(int i = 0;i < 1000;i++){
        if(i*i == x){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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


int MOD=1000000007;


int main() {
	int N;
	cin >> N;
	int d[N+10];
	for(int i=0; i<N; i++) cin >> d[i];
	sort(d,d+N);
	cout << d[N/2]-d[N/2-1] << endl;
}


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

using namespace std;

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

    if (N == 0) {
        cout << X << endl;
        return 0;
    }

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

    int min = *min_element(p.begin(), p.end());
    int max = *max_element(p.begin(), p.end());

    vector<bool> b_table(max+1);
    for (int i = 0; i < N; ++i) {
        b_table[p[i]] = true;
    }

    vector<int> t;
    t.push_back(min-1);
    t.push_back(max+1);
    for (int i = min; i <= max; ++i) {
        if (!b_table[i]) {
            t.push_back(i);
        }
    }

    int min_abs = 100000000;
    int res;
    for (auto i : t) {
        if (abs(X - i) == min_abs) {
            res = std::min(res, i);
        }
        if (abs(X - i) < min_abs) {
            min_abs = abs(X - i);
            res = i;
        }
    }
    cout << res << endl;

}


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

namespace AtCoder.Abc
{
    class B_173_JudgeStatusSummary
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long N = long.Parse(Console.ReadLine());

            // カウント用変数
            int AC = 0;
            int WA = 0;
            int TLE = 0;
            int RE = 0;

            for (int i = 0; i < N; i++)
            {
                // 文字列の入力
                string s = Console.ReadLine();

                switch (s)
                {
                    case "AC":
                        AC++;
                        break;

                    case "WA":
                        WA++;
                        break;

                    case "TLE":
                        TLE++;
                        break;

                    case "RE":
                        RE++;
                        break;
                }
            }

            Console.WriteLine("AC x " + AC);
            Console.WriteLine("WA x " + WA);
            Console.WriteLine("TLE x " + TLE);
            Console.WriteLine("RE x " + RE);
            
            
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 30704
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define fi             first
#define ub             upper_bound
#define se              second
#define mp             make_pair
#define vll            vector<ll>
#define mod            1000000007
#define endl            "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define sz               size()
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)       for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)       {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}


int main()
{
  int T=1 ;
 // cin>>T;
   while(T--)
    {
       ll i,j,k,l,m,n,flag=0;
       ll a=0,b=0,c=0,d=0;
       ll result =1;
    cin>>a>>b>>c>>d;
      vll v;
      v.pb(a*c);
      v.pb(a*d);
      v.pb(b*c);
      v.pb(b*d);
      sort(all(v));
      cout<<v[3]<<endl;


    }
return 0;
}




Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
  int a[5], i, min=9, index, ans=0;
  for(i=0; i<5; i++) cin >> a[i];
  for(i=0; i<5; i++){
    if(min >= a[i]%10 && a[i]%10 != 0){
      min = a[i]%10;
      index = i;
    }
  }
  for(i=0; i<5; i++){
    if(i==index) ans += a[i];
    else{
      if(a[i] % 10 != 0){
        a[i] /= 10; a[i] *= 10; a[i] += 10;
      }
      ans += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
char s[200010];
int main(){
   for(int i=0;;i++){
       scanf("%c",&s[i]);
       if(s[i]=='?'){s[i]='D';}
       else if(s[i]=='\0')break;printf("%c",s[i]);
   }
   
   return 0;
}

Measured memory_bytes: 1772
#include <stdio.h>
#define M 100
#define N 50
int main(){
	int i,j;
	int str[M];
	scanf("%d",&i);
	for(j=0; j<i; j++){
		scanf("%d",&str[j]);
	}
	int m,n,sum=0;
	for(m=0; m<i-1; m++){
		for(n=m+1; n<i; n++){
			sum+=str[m]*str[n];
		}
	}
	printf("%d",sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <iomanip>
#include <limits>
using namespace std;
int main()
{
int n;
double x[10],y[10];
cin>>n;
for (int i=0;i<n;i++)
cin>>x[i]>>y[i];

double sum=0;
for (int i=0;i<n;i++)
{for (int j=i+1;j<n;j++)

sum+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
double c=n-1,d,e;
    for (int i=1;i<=n;i++)

d=n*(n-1)/2;
e=c/d;
cout <<std::setprecision(8) <<sum*e;
}

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

int main()
{
    int N,M;
    cin >> N >> M;
    for(int i = M/N ; i >= 1 ; i--)
    {
        if(M%i == 0)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

def dfs(depth, a, b, c):
	if depth == N:
		if min(a, b, c) > 0:
			MP = abs(A - a) + abs(B - b) + abs(C - c) - 30
		else:
			MP = 10**9
		return MP

	ret0 = dfs(depth + 1, a, b, c)
	ret1 = dfs(depth + 1, a + L[depth], b, c) + 10
	ret2 = dfs(depth + 1, a, b + L[depth], c) + 10
	ret3 = dfs(depth + 1, a, b, c + L[depth]) + 10

	return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2019-04-30
 */
public class Main {

    private int N;
    private int[] array;

    public void init(Scanner sc) {
        N = sc.nextInt();
        array = new int[N];
        for (int idx = 0; idx < N; idx++) {
            array[idx] = sc.nextInt();
        }
    }

    private void printArray() {
        for (int idx = 0; idx < N-1; idx++) {
            System.out.print(array[idx] + " ");
        }
        System.out.println(array[N-1]);
    }

    public void insertionSort() {
        printArray();
        for (int idx = 1; idx < N; idx++) {
            int currEle = array[idx];
            int preIdx = idx-1;
            while ((preIdx >= 0)
                    && (array[preIdx] > currEle)) {
                array[preIdx+1] = array[preIdx];
                preIdx -= 1;
            }
            array[preIdx+1] = currEle;
            printArray();
        }
    }

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



Measured memory_bytes: 30232
# = map(int, input().split())
n = int(input())
# = input()
a = list(map(int, input().split()))

a.sort()

now = a[0]
for i in range(1, n):
	if now == a[i]:
		print("NO")
		exit(0)
	else:
		now = a[i]
print("YES")

Measured memory_bytes: 26808
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout <<"debug "<< i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

ll max[20][100010];
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,l,q;

  std::cin>>n;
  std::vector<ll> x(n);
  rep(i,0,n)std::cin>>x[i];

  std::cin>>l>>q;

  rep(i,0,n)max[0][i]=(ll)(std::upper_bound(all(x),x[i]+l)-x.begin())-1;

  rep(k,1,20){
    rep(i,0,n){
      max[k][i]=max[k-1][max[k-1][i]];
    }
  }



  rep(sdf,0,q){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    if(a>b)std::swap(a,b);
    ll now=a,temp=0;
    for(ll i=(1<<19),pow=19;i>0;i/=2,pow--){
      if(max[pow][now]<b){
        temp+=i;
        now=max[pow][now];
      }
    }
    std::cout<<temp+1<<"\n";
  }

  return 0;
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll A, B, K;
  cin >> A >> B >> K;

  vll wa;
  rep(i, 101) {
    if (i == 0) {
      continue;
    }
    if (A % i == 0 && B % i == 0) {
      wa.pb(i);
    }
  }

  REVERSE(wa);
  COUT(wa[K - 1]);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define sprint(X) printf("%f\n", (X)) // 小数点の出力
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
#define case(X) cout << "Case #" << (X) + 1 << ":" << "\n"
static const int INF = 1e+9+7;

int main(){

  ll A,B;
  cin >> A >> B;

  if(A >= 1 && A <= 9 && B >= 1 && B <= 9){
    print(A * B);
  }
  else print(-1);

 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
const int D_MAX_V=2002;
const int D_v_size=2002;
struct D_wolf{
	int t,c,r;
	D_wolf(){t=c=r=0;}
	D_wolf(int t1,int c1,int r1){
		t=t1;c=c1;r=r1;
	}
};
vector<D_wolf>D_G[D_MAX_V];
int D_level[D_MAX_V];
int D_iter[D_MAX_V];

void add_edge(int from,int to,int cap){
	D_G[from].push_back(D_wolf(to,cap,D_G[to].size()));
	D_G[to].push_back(D_wolf(from,0,D_G[from].size()-1));
}
void D_bfs(int s){
	for(int i=0;i<D_v_size;i++)D_level[i]=-1;
	queue<int> Q;
	D_level[s]=0;
	Q.push(s);
	while(Q.size()){
		int v=Q.front();
		Q.pop();
		for(int i=0;i<D_G[v].size();i++){
			if(D_G[v][i].c>0&&D_level[D_G[v][i].t]<0){
				D_level[D_G[v][i].t]=D_level[v]+1;
				Q.push(D_G[v][i].t);
			}
		}
	}
}
int D_dfs(int v,int t,int f){
	if(v==t)return f;
	for(;D_iter[v]<D_G[v].size();D_iter[v]++){
		int i=D_iter[v];
		if(D_G[v][i].c>0&&D_level[v]<D_level[D_G[v][i].t]){
			int d=D_dfs(D_G[v][i].t,t,min(f,D_G[v][i].c));
			if(d>0){
				D_G[v][i].c-=d;
				D_G[D_G[v][i].t][D_G[v][i].r].c+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	for(;;){
		D_bfs(s);
		if(D_level[t]<0)return flow;
		for(int i=0;i<D_v_size;i++)D_iter[i]=0;
		int f;
		while((f=D_dfs(s,t,99999999))>0){flow+=f;}
	}
	return 0;
}
int pr(int a){
	if(a<=2)return 0;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return 0;
	}
	return 1;
}
int x[310];
int y[310];
int main(){
	int G=0;
	int K=0;
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",y+i);
	int a=0;
	for(int i=0;i<n;i++){
		if(i==0||y[i]!=y[i-1]+1){
			x[a++]=y[i];
		}
		if(i==n-1||y[i]+1!=y[i+1]){
			x[a++]=y[i]+1;
		}
	}
//	for(int i=0;i<a;i++)printf("%d ",x[i]);
//		printf("\n");
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		if(x[i]%2<x[j]%2){
			int t=ABS(x[i]-x[j]);
			if(pr(t)){
	//			printf("%d\n",t);
				add_edge(i,j,1);
			}
		}
	}
	for(int i=0;i<a;i++){
		if(x[i]%2==0){
			add_edge(a,i,1);
			G++;
		}else{
			add_edge(i,a+1,1);
			K++;
		}
	}
	int f=max_flow(a,a+1);
	int ret=f;
	ret+=2*((G-f)/2+(K-f)/2);
	ret+=3*((G-f)%2);
	printf("%d\n",ret);
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;
PII a[MAXN];
pair<PII,int>b[MAXN];
bool cmp(PII a, PII b){
	if(a.ff==b.ff)
		return a.ss>b.ss;
	return a.ff<b.ff;
}
int ans[MAXN];
int d[505][505];
int main()
{
    //~ freopen("file.in", "r", stdin);
    int m,q;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<m;i++){
    	int l,r;
    	scanf("%d%d",&l,&r);
    	d[l][r]++;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			d[i][j]+=d[i][j-1];
	for(int i=0;i<q;i++){
    	int l,r;
    	scanf("%d%d",&l,&r);
    	int s=0;
    	for(int k=l;k<=r;k++)
    		s+=d[k][r]-d[k][l-1];
    	printf("%d\n",s);
	}
	return 0;
	sort(b,b+q);
	
	int x=0,y=0;
	for(int i=0;i<q;i++){
		int l=a[x].ff,r=a[y].ss;
		while(x<m&&l<b[i].ff.ff)
			l=a[++x].ff;
		while(y<=m&&r<=b[i].ff.ss)
			r=a[++y].ss;
		ans[b[i].ss]=y-x;
	}
	for(int i=0;i<q;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 1920
N = int(input())


work = []
for i in range(N):
    A, B = map(int, input().split())
    work.append((A,B))
    

#print(work)
work.sort(key=lambda x: x[1])


sum = 0
flag = 0

for i in range(N):
    sum += work[i][0]
#    print("sum",sum)
    if(sum>work[i][1]):
        flag = 1
        break
    
if(flag==0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 31872
/*Lucky_Glass*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll lena,lenb;
string A,B;
inline ll GCD(ll a,ll b){
	return b? GCD(b,a%b):a;
}
int main(){
	cin>>lena>>lenb>>A>>B;
	ll len=lena*lenb/GCD(lena,lenb);
	ll fA=len/lena,fB=len/lenb;
	ll pos=0;
	for(int i=0;i<lena;i++,pos+=fA){
		if(pos%fB==0)
			if(B[pos/fB]!=A[i]){
				printf("-1\n");
				return 0;
			}
	}
	printf("%lld\n",len);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long
#define PI M_PI

void swap(double *x, double *y){
    double tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

void Bsort(double array[], int N){
    int i, j;
    for(j = 1; j < N; j++){
        for(i = 0; i < N-j; i++){
            if(array[i] > array[i+1]) swap(&array[i], &array[i+1]);
        }
    }
}

int main(void){
    int i;
    int N; scanf("%d",&N);

    double v[N];
    REP(i,N) scanf("%lf",&v[i]);

    Bsort(v, N);

    double ans = 0;
    for(i = 0; i < N-1; i++){
        v[i+1] = (v[i] + v[i+1])/2;
    }
    
    printf("%f", v[N-1]);
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vector<string> s(n);
  REP(i,n)cin>>s[i];

  SORT_UNIQUE(s);
  cout<<s.size()<<endl;

}



Measured memory_bytes: 9540
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  }

  public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  }

  class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  }
}


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

int main() {

  string str;

  cin >> str;

  int c[4] = {};
  for(int i=0;i<str.size();i++) {
    if(str[i] == 'K') c[0]++;
    else if(str[i] == 'U') c[1]++;
    else if(str[i] == 'P') c[2]++;
    else if(str[i] == 'C') c[3]++;
  }

  int ans = 100000000;
  for(int i=0;i<4;i++)
    if(ans > c[i]) ans = c[i];

  cout << ans << endl;


return 0;

}

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

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    rep(i, M) {
        int a;
        cin >> a;
        sum += a;
    }
    if(N - sum < 0) {
        cout << -1 << endl;
        return 0;
    } else {
        cout << N - sum << endl;
        return 0;
    }
}


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

typedef long long int ll;

int main(){
 ll A,B,C;
 cin >> A >> B >> C;
 if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
   cout << 0 << endl;
   return 0;
 } 
 cout << min({A*B,B*C,C*A}) << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

const int MOD = 1000000007;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int rows, cols; cin >> rows >> cols;
	vvi G = vvi(rows, vi(cols, 0));
	rep(r, rows){
		rep(c, cols){
			char block; cin >> block;
			if (block == '.')
				G[r][c] = 1;
		}
	}
	vll row = vll(cols, 0);
	row[0] = 1;
	for(int c = 1; c < cols; c++){
		if (G[0][c]){
			row[c] += row[c-1];
		}
	}
	for(int r = 1; r < rows; r++){
		vll nrow = vll(cols, 0);
		rep(c, cols){
			if (not G[r][c]) continue;
			if (c == 0){
				nrow[0] += row[0];
				nrow[0] %= MOD;
			}else{
				nrow[c] += nrow[c-1];
				nrow[c] += row[c];
				nrow[c] %= MOD;
			}

		}
		row = nrow;
	}
	cout << row[cols-1];
}

Measured memory_bytes: 7076
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <string>

int main() {
	::std::string s, t = "keyence";
	::std::cin >> s;
	for (const auto i : rep<>(0, 7)) {
		const auto j = 7 - i;
		if (s.substr(0, i) + s.substr(s.size() - j, j) == t) {
			::std::cout << "YES" << ::std::endl;
			return 0;
		}
	}
	::std::cout << "NO" << ::std::endl;
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int compat[n][n];
	for (int q = 0; q < n; q++)
	{
		for (int w = 0; w < n; w++)
		{
			cin >> compat[q][w];
		}
	}
	ll dp[1<<n];
	for (int q = 0; q < (1<<n); q++)
	{
		dp[q] = 0;
		for (int w = 0; w < n; w++)
		{
			if ((q & (1<<w)) == 0)
			{
				continue;
			}
			for (int e = w+1; e < n; e++)
			{
				if ((q & (1<<e)) != 0)
				{
					dp[q] += compat[w][e];
				}
			}
		}
	}
	for (int q = 1; q < (1<<n); q++)
	{
		for (int w = q; w > 0; w = (w-1) & q)
		{
			dp[q] = max(dp[q], dp[w] + dp[w ^ q]);
		}
	}
	cout << dp[(1<<n)-1] << "\n";
	return 0;
}


Measured memory_bytes: 768
x = int(input())
bs = [list(map(int, input().split())) for i in range(x)]
box = [[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]]
for b in bs:
    box[b[0]-1][b[1]-1][b[2]-1] += b[3]
for i, b in enumerate(box):
    for bb in b:
        print(" ",end="")
        print(" ".join(map(str,bb)))
    if(i != 3):
        print("####################")


Measured memory_bytes: 5624
/**
 *    author:  math2do
 *    created: 18.05.2020 22:31:35 IST
**/

#include <bits/stdc++.h>

using namespace std;

set <int> hon = {2, 4, 5, 7, 9};
set <int> pon = {0, 1, 6, 8};
set <int> bon = {3};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int d = n % 10;
  if (hon.find(d) != hon.end()) {
    cout << "hon" << endl;
    return 0;
  } 
  if (pon.find(d) != pon.end()) {
    cout << "pon" << endl;
    return 0;
  } 
  if (bon.find(d) != bon.end()) {
    cout << "bon" << endl;
    return 0;
  } 
  return 0;
}


Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))
modulo = 10 ** 9 + 7
cumsum = [1]
for i in range(1, n):
    cumsum.append(cumsum[i - 1] + pow(i + 1, modulo - 2, modulo))
answer = 0
count = 1
for i in range(n):
    answer += a[i] * (cumsum[i] + cumsum[n - i - 1] - 1)
    answer %= modulo
for i in range(n):
    count *= i + 1
    count %= modulo
print(answer * count % modulo)

Measured memory_bytes: 20200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	map<ll, ll> mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (mp.count(a[i])) mp[a[i]]++;
		else mp[a[i]] = 1;
	}

	ll sum = 0;
	for (auto item : mp) {
		sum += item.second * (item.second - 1) / 2;
	}

	for (int i = 0; i < n; i++) {
		ll ans = sum;
		ans -= mp[a[i]] * (mp[a[i]] - 1) / 2;
		ans += (mp[a[i]] - 1) * (mp[a[i]] - 2) / 2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 11392