akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int l = sc.nextInt();
		String[] list = new String[n];
		for(int i = 0; i < n; i++){
		    list[i] = sc.next();
		}
		Arrays.sort(list);
		
		// 計算
		//String result = "NO";
		for(int i = 0; i < n; i++){
		    System.out.print(list[i]);
		}
		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 25244
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string l; cin >> l;
  cpp_int res0 = 2; // 0のところで(0, 0)しか許されないグループの組の数
  cpp_int res1 = 1; // 0のところで(1, 0)が許容されるグループの組の数
  for (size_t i = 1; i < l.size(); ++i) {
    char c = l[i];
    if (c == '0') {
      res0 *= 1; // (0, 0)
      res1 *= 3; // (0, 1), (1, 0), (0, 0)
      // res1 %= MOD;
    }
    else if (c == '1') {
      res1 = (res0 + res1) * 1 + res1 * 2; // (0, 1), (1, 0), (0, 0)
      res0 *= 2; // (0, 1), (1, 0)
      // res0 %= MOD;
      // res1 %= MOD;
    }
    else {
      assert(false);
    }
  }
  cpp_int ans = res0 + res1;
  ans %= MOD;
  cout << ans.str() << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 616
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,arr[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>> arr[i];

    }
    int temp=0,ans=0;
    for(int i=1;i<=n;i++){
        if(arr[i]>arr[i-1]){
            ans=max(ans,temp);
            temp=0;
        }
        else{
            temp++;
        }
    }
    ans=max(ans,temp);
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差

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


int main() {
    long double a,b,c;
    cin >> a >> b >> c;
//    int64 GCD = gcd(a,b);
//    GCD = gcd(GCD, c);
//    a /= GCD;
//    b /= GCD;
//    c /= GCD;

    if ( sqrtl(a) + sqrtl(b) + 1e-14 < sqrtl(c) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
G_MAX = 40*10
N_MAX = 40
INF = float('inf')

dp = [[[INF]*(G_MAX+1) for _ in range(G_MAX+1)] 
      for _ in range(N_MAX+1)]
N,Ma,Mb = map(int, input().split())
a,b,c = [],[],[]
for _ in range(N):
    ai,bi,ci = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)

dp[0][0][0] = 0
from math import isinf
for i in range(N):
    for ca in range(G_MAX+1):
        for cb in range(G_MAX+1):
            if isinf(dp[i][ca][cb]): continue
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb],
                                 dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],
                                           dp[i][ca][cb]+c[i])
            
    
ans = INF
for ca in range(1,G_MAX+1):
    for cb in range(1,G_MAX+1):
        if ca*Mb==cb*Ma:
            ans = min(ans, dp[N][ca][cb])
            
if isinf(ans): ans = -1
print(ans)

Measured memory_bytes: 143452
def q62(N, Y):
    k = Y - 1000*N
    is_true = False
    for i in range(0, N + 1):
        for j in range(0, N - i + 1):
            if 9000*i + 4000*j == k:
                print('{} {} {}'.format(i, j, N - i - j))
                return True
    return False

N, Y = [int(i) for i in input().split()]

if q62(N, Y) == False:
    print('-1 -1 -1')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#define For(N) for (int i = 0; i < N; i++)

using namespace std;
using ll = long long int;
using vi = vector<int>;

int main() {
	int N = 100000;
	vector<bool> v;
	vi sosu;
	vi niteru;
	vi kotae;
	v.resize(N + 2);
	For(N + 1)v[i] = true;
	for (int i = 2; i <= N; i++) {
		if (v[i]) {
			sosu.push_back(i);
			for (int j = i; j <= N; j += i) v[j] = false;
		}
	}
	for (int x : sosu)niteru.push_back(2 * x - 1);

	auto sitr = sosu.begin();
	auto nitr = niteru.begin();
	while (sitr != sosu.end() && nitr != niteru.end()) {
		if (*sitr == *nitr) {
			kotae.push_back(*sitr);
			nitr++;
			sitr++;
		}
		else if (*sitr < *nitr)sitr++;
		else nitr++;
	}
	int Q;
	int l, r;
	cin >> Q;
	while (cin >> l >> r) {
		int ans = 0;
		for (int x : kotae)
			if (l <= x&&x <= r)ans++;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
  ll a, b, c, d;
  cin>>a>>b>>c>>d;
  ll ans = 0;
  ans = max(a*c, max(a*d, max(b*d, b*c)));
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int x,y,z; cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << "\n";



}


Measured memory_bytes: 3616
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  int N;
  cin >> N;

  vector<int> A(N), B(N), C(N);
  for (auto &a : A) {
    cin >> a;
  }
  for (auto &b : B) {
    cin >> b;
  }
  for (auto &c : C) {
    cin >> c;
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  int ans = 0;
  for (auto &b : B) {
    auto ad = lower_bound(A.begin(), A.end(), b);
    int a = distance(A.begin(), ad);

    auto cd = upper_bound(C.begin(), C.end(), b);
    int c = distance(cd, C.end());

    ans += a * c;
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

static const int N_MAX = 100000;

int main(){
  int n,k;
  cin >> n >> k;
  bool number[10];
  for(int i=0;i<10;i++) number[i] = true;

  for(int i=0;i<k;i++){
    int x;
    cin >> x;
    number[x] = false;
  }

  int ans = 0;
  for(int i=n;i<N_MAX;i++){
    bool flag = true;
    ans = i;

    while(ans != 0){
      int x = ans % 10;
      if(number[x] == false) flag = false;
      ans /= 10;
    }

    if(flag){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 



int32_t main()
{
	IOS
	int a,b;cin>>a>>b;
	int m=(a+b)/2;
	if( abs( a-m) == abs(b-m) )cout<<m<<endl;
	else cout<<"IMPOSSIBLE"<<endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(ALL(s));
    s.erase(unique(ALL(s)), s.end());
    cout << s.size() << '\n';
    return 0;
}


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

vector<tuple<ll, vector<ll>>> combination;
vector<tuple<ll, vector<ll>>> v;
ll N, M, X;
ll min_cost = 99999999999LL;

void check(const vector<tuple<ll, vector<ll>>>& v) {

    ll cur_cost = 0;
    ll cur_level[M] = {0};

    for (tuple<ll, vector<ll>> e : v) {
        cur_cost += get<0>(e);

        for(int j = 0; j < M; j++) {
            cur_level[j] += get<1>(e)[j];
        }
       
    }

    bool flag2 = true;
    for(int j = 0; j < M; j++) {
        if(cur_level[j] < X) {
            flag2 = false;
            break;
        }
    }
    if (flag2) {
        if(cur_cost < min_cost) min_cost = cur_cost;
    }
}

void go(int offset, int k) {
  if (k == 0) {
    check(combination);
    return;
  }
  for (int i = offset; i <= N - k; ++i) {
    
    combination.push_back(v[i]);
    go(i+1, k-1);
    combination.pop_back();
  }
}



int main () {

    cin >> N >> M >> X;

    ll c;
    for(int i = 0; i < N; i++) {
        cin >> c;
        vector<ll> aux;

        ll aux2;
        for(int j = 0; j < M; j++) {
            cin >> aux2;
            aux.push_back(aux2);
        }

        v.push_back(make_tuple(c,aux));
    }
    sort(v.begin(), v.end());

    for(int i = 1; i <= N; i++) {
        go(0, i);
    }

    if(min_cost == 99999999999LL) cout << -1 << endl;
    else {
        cout << min_cost;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  vll ans(4);
  ans[0] = a * x + b * y;
  ans[1] = c * 2 * x + max((ll)0, y - x) * b;
  ans[2] = c * 2 * y + max((ll)0, x - y) * a;
  ans[3] = max(x, y) * 2 * c;

  VSORT(ans);
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 764
def fun():
	n = int(input())
	A = list(map(int,input().split()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod*=a
		if(prod>1000000000000000000):
			print(-1)
			return
	print(prod)
 
 
 
fun()

Measured memory_bytes: 21708
A,B,C,X,Y=map(int,input().split())
tmp0 = X*A + Y*B
tmp1 = max(X,Y)*2*C
if X>Y:
    tmp2 = Y*2*C + (X-Y)*A
else:
    tmp2 = X*2*C + (Y-X)*B
print(min(tmp0,tmp1,tmp2))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int a;
  cin >> a;

  cout << a+a*a+a*a*a << "\n";

  return 0;
}


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

using namespace std;

int main() {
  long long n, y;

  cin >> n >> y;

  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= n - i; j++) {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y)
      {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = nextInt()
    val a = nextListOfInt()
    println(abc81b(n,a))
}

fun abc81b(n: Int, a: List<Int>): Int? {
    val arr = a.toIntArray()
    for (i in 0 until n){
        var count = 0
        while (arr[i]%2 == 0){
            arr[i] /= 2
            count++
        }
        arr[i] = count
    }
    return arr.min()
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 36552
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100];
	int m,n,i,j;
	int count = 0;
	int max = 0;
	scanf("%d",&n);
	getchar();
	gets(s);
	for(i = 0;i < n;i++)
	{
		if(s[i] == 'I') 
		{
			count++;
		}
		if(s[i] == 'D')
		{
			count--;
		}
		if(max <= count)
		{
			max = count;
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }


int main()
{
	lint a, b, c;
	cin >> a >> b >> c;
	lint ab = a*b, bc = b*c, ac = a*c;
	lint ans = LLONG_MAX;
	ans = min(ans, abs(bc*(a / 2) - bc*(a / 2 + a % 2)));
	ans = min(ans, abs(ac*(b / 2) - ac*(b / 2 + b % 2)));
	ans = min(ans, abs(ab*(c / 2) - ab*(c / 2 + c % 2)));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stack>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
typedef pair<int, int> P;

int encode(int x, int y, int r, int c) {
    if (y == 0) return x;
    if (x == r) return r + y;
    if (y == c) return r + c + (r - x);
    if (x == 0) return 2*r + 2*c - y;
    return -1;
}

int main(int argc, char** argv) {
    int r, c, n; cin >> r >> c >> n;
    vector<P> pts;
    for (int i = 0; i < n; i++) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        int n1 = encode(x1, y1, r, c), n2 = encode(x2, y2, r, c);
        if (n1 == -1 || n2 == -1) continue;
        pts.push_back(make_pair(min(n1, n2), max(n1, n2)));
    }
    sort(pts.begin(), pts.end());
    stack<int> s;
    for (P p : pts) {
        int n1 = p.first, n2 = p.second;
        while (!s.empty() && s.top() < n1) s.pop();
        if (!s.empty() && s.top() < n2) { cout << "NO\n"; return 0; }
        else s.push(n2);
    }
    cout << "YES\n";
}


Measured memory_bytes: 1400
s = input()
t = input()

min = len(t)
for i in range(len(s)-len(t)+1):
    dif = 0
    for j in range(len(t)):
        if t[j] != s[i+j]:
            dif += 1
    if dif < min:
        min = dif
    # print(dif)
# print()
print(min)

Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int fact[N], infact[N];

int qmi(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)	res = (ll)res * a % mod;
		a = (ll)a * a % mod;
		b >>= 1;
	}
	return res;
}

void init()
{
	fact[0] = 1, infact[0] = 1;
    for(int i = 1; i < N; ++i)
    {
        fact[i] = (ll)fact[i - 1] * i % mod;
        infact[i] = (ll)infact[i - 1] * qmi(i, mod - 2) % mod;
    }
}

int C(int a, int b)
{
	return (ll)fact[a] * infact[b] % mod * infact[a - b] % mod;
}

int main()
{
	int k;
	string s;
	cin >> k >> s;
	
	int len = s.length();
	int n = k + len;
	init();						// 预处理阶乘
	
	int ans = 0;
	for(int i = len; i <= n; i++)
	{
		int t = (ll)C(i - 1, len - 1) * qmi(25, i - len) % mod * qmi(26, n - i) % mod;
		ans = (ans % mod + t % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 20060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


#define int ll

using edge =struct{int to;ll cost;};
vector <edge> tree[100010];
ll aa[100010];
bool used[100010];

void dfs(int v){
    used[v]=true;
    for(auto p:tree[v]){
        if(used[p.to]){
            if(aa[v]+p.cost!=aa[p.to]){
                cout<<"No"<<endl;
                exit(0);
            }
        }else{
            aa[p.to]=aa[v]+p.cost;
            dfs(p.to);
        }
    }
}


int n,m;
int a,b,c;

signed main(){
    cin>>n>>m;
    rep(i,0,m){
        cin>>a>>b>>c;
        a--,b--;
        tree[a].pb({b,c});
        tree[b].pb({a,-c});
    }
    rep(i,0,n){
        if(!used[i])dfs(i);
    }
    cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 15616
import Control.Applicative
import Text.Printf

main = do 
	a:b:_ <- toIntList <$> getLine
	let	d = a `div` b
		m = a `mod` b
		fd = fromIntegral a / fromIntegral b
	putStr $ (show d) ++ " " ++ (show m) ++ " "
	printf "%f\n" (fd::Double)

toIntList :: String -> [Integer]
toIntList = map read . words



Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    bool flg = true;
    for (int i = 0; i < n; i++)
    {
        if (p[i] != i + 1)
        {
            flg = false;
        }
    }
    if (flg)
    {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            vector<int> tmp = p;
            swap(tmp[i], tmp[j]);
            bool rec = true;
            for (int k = 0; k < n; k++)
            {
                if (tmp[k] != k + 1)
                {
                    rec = false;
                }
            }
            if (rec)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 600000

typedef struct{
  int key;
  int par;
  int left;
  int right;
}node;

//void ndset(int,int); 
void maxHeapify(int);

node T[N];

int main(){
  int n,i;

  scanf("%d",&n);

  //same as 9-1.c 
  for(i=0; i<n; i++) T[i].par = -1;

  for(i=0; i<n; i++) scanf("%d",&T[i].key);

  //same as 9-1.c order 
  for(i=0; i<n; i++){
    
    if(i != 0) T[i].par = (i+1)/2-1;

    if(2*(i+1)-1 < n) T[i].left = 2*(i+1)-1;
    else T[i].left = -1;

    if(2*(i+1) < n) T[i].right = 2*(i+1);
    else T[i].right = -1;

  }

  for(i=n/2; i>=0; i--) maxHeapify(i);
  
  for(i=0;i<n;i++) printf(" %d",T[i].key);
  printf("\n");

  return 0;
}


void maxHeapify(int i){

  int l,r,big,temp;

  l = T[i].left;
  r = T[i].right;
  
  if(l != -1 && T[l].key > T[i].key) big = l;
  else big = i; //biggest is the i.
  
  if(r != -1 && T[r].key > T[big].key) big = r;
  
  if(big != i){
    temp = T[big].key;
    T[big].key = T[i].key;
    T[i].key = temp;
  
    maxHeapify(big);

  }
}

Measured memory_bytes: 8784
#include<cstdio>
#include<cstring>
int main(void){
	char a[1500];
	int b;
	int c[30];
	for (int i = 0; i < 1500; i++)a[i] = 0;
	for (int i = 0; i < 30; i++)c[i] = 0;
	for (; scanf("%s", a) != EOF;){
		b = strlen(a);
		for (int i = 0; i < b; i++){
			if (a[i] > 96)c[a[i] - 97]++;
			else c[a[i] - 65]++;
		}
		for (int i = 0; i < b; i++)a[i] = 0;
	}
	for (int i = 0; i < 26; i++)printf("%c : %d\n", i + 97, c[i]);

	return 0;
}

Measured memory_bytes: 2728
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
s=sorted
print(min((s(sum((v[:max(0,len(v)-K+1)]for v in(k*s(v)for k,v in groupby(A,lambda a:a>=Y))),[]))[Q-1:]+[2e9])[0]-Y for Y in A))

Measured memory_bytes: 102108
#include <stdio.h>
struct Node {
  int parent;
  int left;
  int right;
};
int n;
struct Node tree[30];
int dipth[30],height[30];
void getdip(int,int);
int gettree(int);
int getsibling(int);
void printtree(int);
int main(){
  int i,id,left,right,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].parent=tree[i].left=tree[i].right=-1;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left=left;
    tree[id].right=right;
    if(left!=-1)tree[left].parent=id;
    if(right!=-1)tree[right].parent=id;
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)root=i;
  }
  getdip(root,0);
  getheight(root);
  for(i=0;i<n;i++)printtree(i);
  return 0;
}
int getheight(int root){
  int h1=0,h2=0;
  if(tree[root].left!=-1)h1=getheight(tree[root].left)+1;
  if(tree[root].right!=-1)h2=getheight(tree[root].right)+1;
  if(h1>h2)height[root]=h1;
  else height[root]=h2;
  return height[root];
}
int getsibling(int num){
  if(tree[num].parent==-1)return -1;
  if(tree[tree[num].parent].left!=num&&tree[tree[num].parent].left!=-1)return tree[tree[num]\
.parent].left;
  else if(tree[tree[num].parent].right!=num&&tree[tree[num].parent].right!=-1)return tree[tr\
ee[num].parent].right;
  return -1;
}
void getdip(int r,int d){
  if(r==-1)return;
  dipth[r]=d;
  if(tree[r].right!=-1)getdip(tree[r].right,d+1);
  if(tree[r].left!=-1)getdip(tree[r].left,d+1);
}
void printtree(int i){
  int m,j=0,digree=0;
  if(tree[i].right!=-1)digree++;
  if(tree[i].left!=-1)digree++;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree\
[i].parent,getsibling(i),digree,dipth[i],height[i]);
  if(tree[i].parent==-1)printf("root");
  else if(tree[i].left==-1&&tree[i].right==-1)printf("leaf");
  else printf("internal node");
  printf("\n");
}


Measured memory_bytes: 2052
def getInput():
    n = int(input())
    a = [int(i) for i in input().split(" ")]
    return n, a

def swap(x, y):
    v = x
    x = y
    y = v
    return x, y

def selectionSort(n, a):
    cnt = 0
    for i in range(n):
        id_min = i
        for j in range(i+1, n):
            if a[j] < a[id_min]:
                id_min = j
        if id_min != i:
            a[i], a[id_min] = swap(a[i], a[id_min])
            cnt += 1
    print(" ".join([str(i) for i in a]))
    print(cnt)
    return

n, a = getInput()
selectionSort(n, a)



Measured memory_bytes: 5608
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

S, T = input().split()
A, B = map(int,input().split())
U = input()

if S == U:
  print(A-1, B)
else:
  print(A, B-1)



Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int n;
void dfs(string s,char mx){
    if(s.size()==n){
        std::cout << s << std::endl;
        return ;
    }
    else{
        for (char i = 'a'; i <=mx ; i++) {
            /* code */
            int dmx=mx;
            if(i==mx)dmx++;
            dfs(s+i,dmx);
        }
    }
}
int main(){
    std::cin >> n;
    dfs("",'a');
}

Measured memory_bytes: 1536
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using PII = pair<int,int>;
void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }//


ll solve(int N, vi &L){
	ll ans = 0;

	rp(ia,0,N-2){
		ll a = L[ia];
		rp(ib,ia+1,N-1){
			ll b = L[ib];
			rp(ic,ib+1,N){
				ll c = L[ic];
				int minL = min({a,b,c});
				int maxL = max({a,b,c});
				int midL = a+b+c-minL-maxL;
				// printf("min %d mid %d max %d\n",minL,midL,maxL);//
				if(maxL < minL+midL ){
					ans++;
				}
			}
		}
	}

	return ans;
}

int main(){
	int N; cin>>N;
	vi L(N);
	rp(i,0,N)cin>>L[i];
	ote(solve(N, L));
}


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

int main(){
    string S;
    int num,ans=1000;
    int k[10]={753};

    cin >> S;
    

    for(int i=0;i<S.length()-2;i++){
        num = stoi(S.substr(i,3));
        k[i] = abs(num - 753);
    }

    for(int i=0;i<S.length()-2;i++){
        if(k[i] < ans){
            ans = k[i];
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
import sys

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

for ab in sys.stdin:
    a,b=map(int,ab.split(" "))
    if a<=b:
        tmp = a
        a = b
        b = tmp
    g = gcd(a,b)
    l = a*b/g
    print g,l

Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  // if(N%108!=0){
  //   cout<<":("<<endl;
  //   return 0;
  // }
  REP(x, 0, N+1) {
    int Y = x * 1.08;
    if (Y == N) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

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

int n;
ll p[105];
ll dp[105][105];

int main(){

  cin >> n;
  rep(i,0,n){
    cin >> p[i] >> p[i+1];
  }

  fill(dp[0],dp[105],INF);
  rep(i,0,104){
    dp[i][i+1] = 0;
  }

  rep(k,2,n+1) rep(i,1,n+1){
    int j = i+k;
    if(j>=n+2)continue;
    rep(l,i,j-1) {
      dp[i][j] = min(dp[i][j],dp[i][l+1] + dp[l+1][j] + p[i-1]*p[l]*p[j-1]);
      //cout << i<<j<<k<<l << " " << dp[i][j] << endl;
    }
  }

  cout << dp[1][n+1] << endl;

  return 0;
}



Measured memory_bytes: 3164
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXQ = 1007;
const int MAXN = 10007;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	VLL a(n);
	FOR(i, 0, n)
		cin >> a[i];

	LL ans = 0;
	LL s = 0;
	FOR(i,0,n)
		if (a[i])
		{
			s += a[i];
		}
		else
		{
			ans += s / 2;
			s = 0;
		}

	ans += s / 2;
	cout << ans;
	cin >> n;

	return 0;
}

Measured memory_bytes: 1024
# coding:utf-8


from math import floor

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)


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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			int count = 0;
			for(int i = 0;i < N ;i++) {
				str = br.readLine();
				String[] s = str.split(" ",0);
				int l = Integer.parseInt(s[0]);
				int r = Integer.parseInt(s[1]);
				count += (r - l + 1);
			}
			System.out.println(count);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


Measured memory_bytes: 25556
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b;
  cin>>a>>b;
  ll res = min(a, b/2);
  a -= res; b -= 2*res;
  if(b) res += b/4;
  cout<<res<<endl;
	return 0;
}


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

int main()
{
    long long n,p=0,area=1;
    cin>>n;
    long long side[n];
    for(int i=0;i<n;i++){
        cin>>side[i];
    }
    sort(side,side+n,greater<int>());
    for(int i=0;i<n-1;i++){
        if(side[i]==side[i+1]){
            p++;
            area=area*side[i];
            i++;
        }
        if(p==2){
            cout<<area<<endl;
            return 0;
        } 
    }
    cout<<'0'<<endl;
    return 0;
}

Measured memory_bytes: 4340
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

int num[21];
int fact[21];
int ans[11][1101];

int main() {
  for (int i=0; i<10; i++) {
    num[i] = i;
  }

  fact[0] = 1;
  for (int i=1; i<=10; i++) {
    fact[i] = fact[i-1] * i;
  }

  do {
    int sum = 0;
    for (int i=0; i<10; i++) {
      sum += num[i]*(i+1);
      ans[i+1][sum]++;
    }
  } while (next_permutation(num, num+10));

  while (1) {
    int n, s;
    if (scanf("%d%d", &n, &s) != 2) return 0;
    if (s >= 1000) puts("0");
    else printf("%d\n", ans[n][s]/fact[10-n]);
  }
}

Measured memory_bytes: 2764
// Last Change: 06/22/2019 21:26:17.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS
ll gcd(ll a, ll b) {
  if (a == 0 and b == 0)
    return 0;
  a = abs(a);
  b = abs(b);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

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

int main() {
  ll A, B, C, D, E;
  cin >> A >> B >> C >> D;

  --A;
  ll ans = B - A;
  ans -= B / D - A / D;
  ans -= B / C - A / C;

  E = lcm(C, D);
  ans += B / E - A / E;

  cout << ans << endl;
}


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

typedef pair<int,int> P;

// デバッグ出力
void debug(vector<P> v, int i){
	cout << "Line " << i << endl;
	for(int i=0 ; i < v.size() ; i++ ){
		cout << "(" << v[i].first << "," << v[i].second << ")" << endl;
	}
	cout << endl;
}

int main(){
	int n;
	while( cin >> n , n ){
		// 折れ線の集まり
		vector< vector<P> > list(n+1);
		// 答えの番号
		vector<int> ans;
		
		// n+1 の折れ線
		for(int i=0 ; i <= n ; i++ ){
			int m, sx, sy;
			vector<P> v;
			
			cin >> m;
			// 1つの折れ線は m 個の頂点を持つ
			for(int j = 0 ; j < m ; j++ ){
				int x,y;
				
				cin >> x >> y;
				if( j == 0 ){
					sx = x;
					sy = y;
					v.push_back( P(0,0) );
				}else{
					v.push_back( P(x-sx,y-sy) );
				}
			}
			//debug( v , i );
			list[i] = v;
		}
		
		// list[0]と同じものを探す
		for(int i=1 ; i <= n ; i++ ){
			// 頂点の数が同じかどうか
			if( list[0].size() == list[i].size() ){
				// 回転した4パターンを調べる
				for(int k=0 ; k < 4 ; k++ ){
					bool flag = true;
					// 90度回転
					for(int j=0 ; j < list[0].size() ; j++ ){
						int x = list[i][j].first;
						int y = list[i][j].second;
						list[i][j].first  = y ;
						list[i][j].second = -x;
					}
					//cout << "90 turn!" << endl;
					//debug( list[i] , i );
					// 各点が同じかどうか調べる
					for(int j=0 ; j < list[0].size() ; j++ ){
						int x1 = list[0][j].first;
						int y1 = list[0][j].second;
						int x2 = list[i][j].first;
						int y2 = list[i][j].second;
						if( x1 != x2 || y1 != y2 ){
							flag = false;
							break;
						}
					}
					if( flag ){
						ans.push_back( i );
						break;
					}
					
					// 逆から各点が同じかどうか調べる
					flag = true;
					vector<P> r_line = list[i];
					reverse( r_line.begin() , r_line.end() );
					int sx, sy;
					for(int j=0 ; j < r_line.size() ; j++ ){
						if( j == 0 ){
							sx = r_line[j].first;
							sy = r_line[j].second;
						}
						r_line[j].first -= sx;
						r_line[j].second -= sy;
					}
					//cout << "90 turn. reverse!" << endl;
					//debug( r_line , i );
					for(int j=0 ; j < list[0].size() ; j++ ){
						int x1 = list[0][j].first;
						int y1 = list[0][j].second;
						int x2 = r_line[j].first;
						int y2 = r_line[j].second;
						if( x1 != x2 || y1 != y2 ){
							flag = false;
							break;
						}
					}
					if( flag ){
						ans.push_back( i );
						break;
					}
				}
			}
		}
		
		// 解の出力
		for(int i=0 ; i < ans.size() ; i++ ){
			cout << ans[i] << endl;
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

ans = 1
tmp = A[0]

for a in A[1:]:
    if a <= tmp*2:
        ans += 1
    else:
        ans = 1
    tmp += a

print(ans)

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

// 0-indexed
template <class T>
struct BIT {
  int treesize;
  vector<T> lst;
  // constructor
  BIT(int newn = 0) : treesize(newn), lst(newn + 1, 0) {}
  // a_place += num
  void add(int place, T num) {
    ++place;
    while (place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
  }
  // sum between [0,place)
  T sum(int place) {
    T res = 0;
    while (place > 0) {
      res += lst[place];
      place -= place & -place;
    }
    return res;
  }
  // sum [l,r)
  T sum(int left, int right) { return sum(right) - sum(left); }
};

struct EulerTour {
  int n, root;
  vector<vector<int>> g;
  vector<int> par, dep, in, out, lst;
  EulerTour(int n = 1, int _root = 0)
      : root(_root), g(n), par(n), dep(n), in(n), out(n) {}
  EulerTour(const vector<vector<int>> &_g, const int _root = 0)
      : root(_root),
        g(_g),
        par(_g.size()),
        dep(_g.size()),
        in(_g.size()),
        out(_g.size()) {
    build();
  }
  void add(int a, int b) {
    g[a].push_back(b);
    g[b].push_back(a);
  }
  void build() {
    lst.clear();
    dfs(root, -1, 0);
  }
  void dfs(int now, int bf, int d) {
    dep[now] = d;
    par[now] = bf;
    in[now] = lst.size();
    lst.push_back(now);
    for (auto &to : g[now])
      if (to != bf) {
        dfs(to, now, d + 1);
        lst.push_back(now);
      }
    if (lst.back() != now) lst.push_back(now);
    out[now] = lst.size();
  }
  int chil(int x, int y) { return dep[x] < dep[y] ? y : x; }
};


long long n;
vector<int> c;
vector<vector<int>> edge, col, memo;

void solve();

int main() {
  cin >> n;
  c.resize(n);
  edge.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    --c[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  solve();
  return 0;
}

void solve() {
  EulerTour et(edge);
  BIT<long long> bit(et.lst.size());
  col.resize(n);
  memo.resize(n);
  for (int i = 0; i < n; ++i) bit.add(et.in[i], 1);
  for (int i = 0; i < et.lst.size(); ++i) memo[et.lst[i]].push_back(i);
  for (int i = 0; i < n; ++i) col[c[i]].push_back(i);
  for (int i = 0; i < n; ++i) {
    long long res = n * (n + 1) / 2;
    using P = pair<int, int>;
    vector<P> v;
    map<int, int> mp;
    for (int node : col[i]) {
      bit.add(et.in[node], -1);
      mp[node] = 1;
      for (int id = 0; id < (int)memo[node].size() - 1; ++id)
        v.emplace_back(memo[node][id + 1], node);
    }
    sort(v.begin(), v.end());
    for (P p : v) {
      long long now = bit.sum(et.in[p.second], p.first);
      res -= now * (now + 1) / 2;
      mp[p.second] += now;
      bit.add(et.in[p.second], -now);
    }
    long long last = bit.sum(et.lst.size());
    res -= last * (last + 1) / 2;
    cout << res << endl;
    for (auto p : mp) bit.add(et.in[p.first], p.second);
  }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int c = b - a;
	int d = 0;
	for (int i = 1; true; ++i) {
		//cout << "d=" << d << " i=" << i << endl;
		if (i == c) {
			cout << d - a << endl;
			exit(0);
		}
		d += i;
	}
}

Measured memory_bytes: 256