akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

int main(){

    long long int n,tmp;
    cin>>n;

    map<long long int,long long int> mp;
    for(int i=0;i<n;i++){
        cin>>tmp;
        mp[-tmp]++;
    }
    long long int tate=0,yoko=0;
    for(auto x:mp){
        if(x.second>=2){
            tate=x.first;
            mp[tate] -= 2;
            break;
        }
    }
    for(auto x:mp){
        if(x.second>=2){
            yoko=x.first;
            break;
        }
    }
    cout<<tate*yoko<<endl;
}


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

int N;
pair<int, int> workstime[100000];

int main() {

	string s;
	string t;

	cin >> s;
	cin >> t;
	int ans = 0;

	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])
			ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max(a*c,max(a*d,max(b*c,b*d))) << endl;
	return 0;
}

Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Text;
using CompLib.Util;

public class Program
{
    int N, M;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        var sb = new StringBuilder();
        int odd = (M + 1) / 2;
        int l = 1;
        int r = odd * 2;
        for (int i = 1; i <= odd; i++)
        {
            sb.AppendLine($"{l++} {r--}");
        }

        int even = M - odd;
        l = odd * 2 + 1;
        r = l + even * 2;
        for (int i = 0; i < even; i++)
        {
            sb.AppendLine($"{l++} {r--}");
        }


        Console.Write(sb);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 39912
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  ll n, m;
  cin >> n >> m;
  if(n == 1 || m == 1)
    cout << max(1LL, n - 2) * max(1LL, m - 2) << endl;
  else
    cout << (n - 2) * (m - 2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int t, x;
   cin >> t >> x;
   cout << (double) t / x << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
ll n , m ,k;
ll nbr;

int main()
{
	IOS;
	 std::cout << std::setprecision(30);
    ll n,k;
    cin >> n >> k;
    vector<ll> dp(n,0);
    string ch="";
    for(int i=0;i<n;i++)
    {
        ch+='0';
    }
    ch[0]='1';

    for(int i=0;i<k;i++)
    {
        ll x,y;
        cin >> x >> y;
        if(dp[x-1]==0 || dp[x-1]==y)
            {dp[x-1]=y; ch[x-1]=(y+'0');}
        else
            return cout << -1,0;


    }
    if(n==1 && k==0)
        cout << 0;
    else if(ch[0]=='0' && n!=1)
        cout << -1;
    else
        cout << ch;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, ld>;

int main() {
    ld sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int n;
    cin >> n;
    vector<ld> x(n), y(n), r(n);
    rep(i, n)cin >> x[i] >> y[i] >> r[i];
    vector<vector<P>> to(n+2);
    rep(i, n)rep(j, n){
        if(i >= j)continue;
        ld d = (x[i] - x[j]) * (x[i] - x[j]);
        d += (y[i] - y[j]) * (y[i] - y[j]);
        d = sqrt(d);
        d = max((ld)0, d - r[i] - r[j]);
        to[i+1].push_back(make_pair(j+1, d));
        to[j+1].push_back(make_pair(i+1, d));
    }
    rep(i, n){
        ld d = (x[i] - sx) * (x[i] - sx);
        d += (y[i] - sy) * (y[i] - sy);
        d = max((ld)0, sqrt(d) - r[i]);
        to[0].push_back(make_pair(i+1, d));
        to[i+1].push_back(make_pair(0, d));
        d = (x[i] - tx) * (x[i] - tx);
        d += (y[i] - ty) * (y[i] - ty);
        d = max((ld)0, sqrt(d) - r[i]);
        to[n+1].push_back(make_pair(i+1, d));
        to[i+1].push_back(make_pair(n+1, d));
    }
    ld distance = (sx - tx) * (sx - tx) + (sy - ty) * (sy - ty);
    distance = sqrt(distance);
    to[0].push_back(make_pair(n+1, distance));
    to[n+1].push_back(make_pair(0, distance));

    ld INF = 1e11;
    vector<ld> d(n+2, INF);
    d[0] = 0;
    priority_queue<pair<ld, int>, vector<pair<ld, int>>, greater<pair<ld, int>>> que;
    que.push(make_pair(0, 0));
    while(!que.empty()){
        pair<ld, int> p = que.top();
        que.pop();
        ld dist = p.first;
        int v = p.second;
        if(dist > d[v])continue;
        for(P t : to[v]){
            if(d[t.first] > d[v] + t.second){
                d[t.first] = d[v] + t.second;
                que.push(make_pair(d[t.first], t.first));
            }
        }
    }
    
    cout << setprecision(14);
    if(d[n+1] == INF)cout << -1 << endl;
    else cout << d[n+1] << endl;
    
}

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

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


int main(void) {
    int N;
    cin >> N;
    double p[N];
    rep(i, N) cin >> p[i];



    double dp[N+1][N+1];
    rep(i,N+1){
        rep(j,N+1){
            dp[i][j] = 0.0;
        }
    }

    dp[0][0] = 1.0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= i; j++) {
            if(j >= 1){
                dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1.0 - p[i-1]);
            } else {
                dp[i][j] = dp[i-1][j] * (1.0 - p[i-1]);
            }
        }
    }

    // rep(i,N+1){
    //     rep(j,N+1){
    //         cout << dp[i][j] << endl;
    //     }
    // }

    double ans = 0.0;
    for(int i = (N/2)+1; i <= N; i++) {
        // cout << dp[N][i] << endl;
        ans += dp[N][i];
    }
    // 浮動小数点数を出力する精度を設定する(制約10桁)
    cout << setprecision(10) << scientific << ans << endl;

    return 0;
}

Measured memory_bytes: 70528
N=gets.to_i
answers=[]
N.times do
  n_ans = gets.to_i
  anss = []
  n_ans.times do |ans|
    toks = gets.split
    raise if toks.size != 2
    anss << [toks[0].to_i - 1, toks[1].to_i]
  end
  answers << anss
end

best = 0
(2**N).times do |i|
  bin = "%0#{N}b" % i
  cur = bin.count('1')
  ok = true
  N.times do |j|
    next if i[j] == 0
    answers[j].each do |k, v|
      if i[k] != v
        ok = false
        break
      end
    end
    if !ok
      break
    end
  end
  if ok
    best = [best, cur].max
  end
end

p best



Measured memory_bytes: 1788
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

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

using namespace std;

int main()
{
    int pow3[16];
    pow3[0] = 1;
    for(int i = 1; i <= 15; i++)
    {
        pow3[i] = 3*pow3[i-1];
    }
    int n,m,k;
    int p,x,y;
    while(cin >> n >> m)
    {
        if((n == 0)&&(m == 0)) break;
        vector<int>v(n);
        for(int i = 0; i < 3; i++)
        {
            cin >> k;
            for(int j = 0; j < k; j++)
            {
                int tmp;
                cin >> tmp;
                v[n-tmp] = i;
            }
        }
        p = 0;
        x = 0;
        for(int i = n - 1; i >= 0; i--)
        {
            int d = abs(p-v[i]);
            x += pow3[i]*d;
            if(d == 1) p = 2-p;
        }
        y = pow3[n] - 1 -x;
        int ans = min(x,y);
        if(ans > m) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}


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

int main() {
    long long int a,b,x,ans,a1,b1;cin>>a>>b>>x;
    a1=(a-1)/x;
  if(a==0)a1=-1;
//    if(a%x!=0)a1-=1;
    b1=b/x;
//    if(b%x==0)b1+=1;
    ans=b1-a1;

    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#Educational DP Contest
#F-LCS

s = input()
t = input()
n = len(s)
m = len(t)

#dp table
dp = [[0]*(m+1) for _ in range(n+1)]

#process1
for i in range(1,n+1):
    for j in range(1,m+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] +1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]) #2箇所参照することに注意

#output process
"""
LCSの長さを求めるなら以下で正解
print(dp[-1][-1])
"""

#今回求めるのは、その文字列
#後ろ側から共通のものを足していく
ans = ""
while True:
    if n == 0 or m == 0: #sかtどちらかの文字列を先頭まで参照したらbreak
        break
    if dp[n][m] == dp[n-1][m]:
        n -= 1
    elif dp[n][m] == dp[n][m-1]:
        m -= 1
    else: #どちらの数字も変動するとき=共通文字の時
        n,m = n-1,m-1 #処理順序に注意
        ans = s[n] + ans #前に足す(なお、t[m]でも同じことが言える)

print(ans)

Measured memory_bytes: 112220
n=input().split()
N=int(n[0])
M=int(n[1])
a=input().split()
#print(a)
a = [int(i) for i in a] 
b=sum(a)/(4*M)
c=sorted(a)[Ｍ*-1]
if  b <= c :
     print("Yes")
else:
     print("No")

Measured memory_bytes: 3064
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	stringstream ss;
	ss << n;
	string s;
	ss >> s;
	string r = s;
	reverse(r.begin(), r.end());
	cout << (s == r ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000
using namespace std;
typedef long long LL;
class memo
{
private:
    int A,B,C,D,E,F;
    bool table[3005];
    int frontmin[3005];
    int tablew[3005];
    int frontwmin[3005];

public:
    void in()
    {
        cin>>A>>B>>C>>D>>E>>F;
    }
    void slove();
    memo();
};
memo::memo()
{
    memset(table,0,sizeof(table));
    memset(frontmin,0,sizeof(frontmin));
    memset(tablew,0,sizeof(tablew));
    memset(frontwmin,0,sizeof(frontwmin));
}
void memo::slove()
{
    int a,b;
    a = A*100,b = B*100;
    double maxx = 0;
    int ia = 0,ib,ic = 0;
    for(int i = 0; i <= F/C; i++)
    {
        for(int j = 0; j <= F/D; j++)
        {
            if(i*C + j*D <= F)
                table[i*C + j*D] = true;
        }
    }
    for(int i = 0; i <= F; i++)
    {
        if(table[i])
            frontmin[i] = i;
        else  frontmin[i] = frontmin[i-1];
    }
    for(int i = 0; i <= F/a; i++)
    {
        for(int j = 0; j <= F/b; j++)
        {
            if(i*a + j*b <= F)
                tablew[i*a+j*b] = true;
        }
    }
    for(int i = 1; i <= F; i++)
    {
        if(tablew[i])
        {
            int sum = F - i;
            int sumr = i/100*E;
            sumr = min(sum,sumr);
            sumr = frontmin[sumr];
            if((maxx <= 1.0*sumr/(i+sumr))&&i+sumr!=0)
                maxx = 1.0*sumr/(i+sumr),ia = sumr + i,ic = sumr;
        }
    }
    printf("%d %d\n",ia,ic);
}
int main(void)
{
    memo ask;
    ask.in();
    ask.slove();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        Box[] boxes = new Box[n];

        for (int i = 0; i < n; i++) {
            boxes[i] = new Box();
        }
        boxes[0].red = 1;
        boxes[0].white = 0;
        boxes[0].isPossible = true;

        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;

            boxes[y].red += boxes[x].red;
            boxes[y].white += boxes[x].white;

            boxes[x].num--;
            boxes[y].num++;

            if (boxes[x].num == 0) {
                boxes[x].red = 0;
                boxes[y].white = 0;
            }
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (boxes[i].red > 0) count++;
        }

        System.out.println(count);
    }

    private static class Box {
        int num = 1;
        int red = 0;
        int white = 1;
        boolean isPossible = false;
    }
}

Measured memory_bytes: 27052
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 7;i > 0;i--) {
        if(pow(2, i)<=n) {
            cout << pow(2, i) << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
def main(n: int, m: int, a: list):
    ans = 0
    base = sum(a) / (4 * m)

    for i in a:
        if i >= base:
            ans += 1

        if ans >= m:
            print("Yes")
            return

    print("No")


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    main(n, m, a)


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

class U {
public:
  int n;
  vector<int> p, s;

  U(int _) {
    n = _;
    p.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
      s[i] = 1;
    }
  }

  bool connect(int a, int b) {
    int ap, bp;
    for (ap = p[a]; ap != p[ap]; ap = p[ap]);
    for (bp = p[b]; bp != p[bp]; bp = p[bp]);
    if (ap == bp)
      return true;
    int mi = min(ap, bp), ma = max(ap, bp);
    p[ma] = mi;
    s[mi] += s[ma];
    s[ma] = 0;
    for (int pp = a; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    for (int pp = b; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    return false;
  }

  int q(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return s[ap];
  }

  int parent(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return p[ap];
  }

  bool query(int a, int b) { return parent(a) == parent(b); }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  U u(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    u.connect(a, b);
  }
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    if (!u.connect(0, i)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3992
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
vector<llint>prime;
void init(void){
	//2200まででよい
	for(llint i=2;i<2200;i++){
		bool ok=true;
		for(auto j:prime){
			if(j*j<=i){break;}
			if(i%j==0){ok=false;break;}
		}
		if(ok){prime.pub(i);}
	}
}
pair<llint,pair<llint,llint>> han(llint in){//3乗を除いたもの,1乗部分,2乗部分の平方根
	pair<llint,llint> ans;
	ans=mp(1LL,1LL);
	int gen;
	for(auto i:prime){
		gen=0;
		while(in%i==0){in/=i;gen++;}
		if(gen%3==1){ans.fir*=i;}
		if(gen%3==2){ans.sec*=i;}
	}
	ans.fir*=in;
	return mp(ans.fir*ans.sec*ans.sec,ans);
}
int main(void){
	init();
	llint ans=0;
	int i,n;cin>>n;
	map<llint,pair<llint,pair<llint,llint>>> a;//惨状を除く,回数,1部,2部
	llint q;
	for(i=0;i<n;i++){
		cin>>q;
		auto ret=han(q);
		auto dai=mp(a[ret.fir].fir+1,ret.sec);
		a[ret.fir]=dai;
	}
	for(auto itr=a.begin();itr!=a.end();itr++){
		auto &it=*itr;
		if(it.fir==1){ans++;continue;}
		if(it.sec.sec.fir>100000){ans+=it.sec.fir;continue;}
		llint th=it.sec.sec.fir*it.sec.sec.fir*it.sec.sec.sec;
		if(a.count(th)!=0){
			ans+=max(a[th].fir,it.sec.fir);
			a[th].fir=0;it.sec.fir=0;
		}
		else{ans+=it.sec.fir;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)
#print(xyh)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) < hres:
                ok = -1
                break
    if ok == 0:
        print(cx, cy, hres)
        break


Measured memory_bytes: 3064
#include <iostream>

int main()
{
	int A = 0, B = 0, C = 0;
	int store = 0;

	std::cin >> A >> B >> C;

	if (A == B && B == C && C == A)
	{
		std::cout << "No" << std::endl;
		return 0;
	}
	else if (A==B||B==C||C==A)
	{
		std::cout << "Yes" << std::endl;
		return 0;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e+5 + 100;
int len[LIM];
int main()
{
	int n, l;
	cin >> n >> l;
	for (int i = 0; i < n; ++i)
		cin >> len[i];
	int id = -1;
	for (int i = 1; i < n; ++i)
		if (len[i - 1] + len[i] >= l)
			id = i;
	if (id == -1)
	{
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << '\n';
	for (int i = 1; i < id; ++i)
		cout << i << '\n';
	for (int i = n - 1; i >= id + 1; --i)
		cout << i << '\n';
	cout << id << '\n';
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  if((N-1000*(N/1000))%111 == 0 || (N-N%10)%1110 == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}
  
  
  

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

#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;

int main()
{
	int d, g;
	cin >> d >> g;
	vector <int> p(d);
	vector <int> c(d);
	vector <int> s(d);
	rep(i, d) {
		cin >> p[i] >> c[i];
		s[i] = 100 * (i + 1) * p[i] + c[i];
	}

	int ans = INF;
	int sum = 0;
	int re;
	int pm = 0;
	for (int bit = 0; bit < (1 << d); bit++) {
		vector <int>  repro;
		for (int i = 0; i < d; i++) {
			if (bit & (1 << i)) {
				sum += s[i];
				pm += p[i];
			}
			else {
				repro.push_back(i);
			}
		}
		re = g - sum;
		if (re <= 0) {
			ans = min(ans, pm);
		}
		else {
			int tsum = 0;
			bool flag = false;
			//sort(repro.begin(), repro.end(), greater<int>());
			reverse(repro.begin(), repro.end());
			for (int v : repro) {
				for (int k = 0; k < p[v]; k++) {
					if (tsum >= re) {
						flag = true;
						break;
					}
					tsum += (v + 1) * 100;
					pm++;
				}
				if (flag)  break;
			}
			ans = min(ans, pm);
		}
		pm = 0;
		sum = 0;
	}
	cout << ans << endl;
}

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

int main(void){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll a[n];
    for(int i=0; i<n; i++){
    	cin>>a[i];
    	a[i]-=(i+1);
	}
	sort(a, a+n);
	ll pre[n];
	pre[0] = a[0];
	for(int i=1; i<n; i++){
		pre[i] = a[i]+pre[i-1];
	}
	
	ll mn = 1e18;
	for(int i=0; i<n; i++){
		ll v1 = 0, v2 = 0;
		if(i!=0){
			v1 = pre[i-1];
		}
		v2 = pre[n-1]-pre[i];
		v1 = i*a[i]-v1;
		v2 = v2 - (n-1-i)*a[i];
		mn = min(mn, v1+v2);
	}
	cout<<mn<<endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#define MOD 1000000007
int dp[3005][3005][2];
int main()
{
	// freopen("AGC013-D.in", "r", stdin);
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i++)
		dp[0][i][!i] = 1;
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			for (int x = 0; x < 2; x++)
			{
				if (j)
				{
					(dp[i + 1][j - 1][x | !(j - 1)] += dp[i][j][x]) %= MOD;
					(dp[i + 1][j][x | !(j - 1)] += dp[i][j][x]) %= MOD;
				}
				if (j != n)
				{
					(dp[i + 1][j + 1][x] += dp[i][j][x]) %= MOD;
					(dp[i + 1][j][x] += dp[i][j][x]) %= MOD;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
		(ans += dp[m][i][1]) %= MOD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        int[] dArr = ReadLineIntArray();
        Array.Sort(dArr);
        if (dArr[(n / 2) -1] == dArr[n / 2]) {
            Console.WriteLine(0);
        } else {
            Console.WriteLine(dArr[n / 2] - dArr[(n / 2) -1]);
        }
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"};
    static int[] intArray = new int[10];
    static List<int> intList = new List<int>();
    static Dictionary<string, int> myTable = new Dictionary<string, int>();
    static HashSet<int>[] rtnArrAb = null;
    static HashSet<int>[] rtnArrCd = null;
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private List<int> ReadLineIntList() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList();}
    static private List<long> ReadLineLongList() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToList();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
  
    static private string IntToNString(int x, int n) {
        var nstring = "";
        var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
        int r = 1;
        int q = x;
        while (q > 0) {
            r = q % n;
            nstring += numbers[r];
            q = q / n;
        }
        return string.Join("",nstring.Reverse());
     }
}

Measured memory_bytes: 20448
package main

import (
  "fmt"
  "math"
  "strconv"
)

func main() {

  var a, b string

  fmt.Scan(&a, &b)
  
  var ab, rooted float64
  ab, _ = strconv.ParseFloat(a+b, 64)
  rooted = math.Sqrt(ab)
  

  if rooted == math.Trunc(rooted) {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,m;
    cin >> n >> m;

    bool can[n+10];
    int wa[n+10];
    rep(i,n+10){
        can[i]=false;
        wa[i]=0;
    }

    int x,ac=0,pt=0;
    string s;
    for (int i = 0; i < m; i++)
    {
        cin >> x >> s;
        if(can[x]==false && s=="AC"){
            can[x]=true;
            ac++;
            pt+=wa[x];
        }
        else if(can[x]==false && s=="WA"){
            wa[x]++;
        }
    }
    cout << ac << " " << pt << endl;
    
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int arr[55],n;
bool ok(){
	F(i,0,n-1) if(arr[i]>arr[i+1]) return 0;
	return 1;
}
int main(){
	while(~getI(n)){
		F(i,0,n) getI(arr[i]);
		bool flag=0;
		F(i,0,n) F(j,i,n){
			int tmp=arr[i];
			arr[i]=arr[j];
			arr[j]=tmp;
			if(ok()) flag=1;
			tmp=arr[i];
			arr[i]=arr[j];
			arr[j]=tmp;
		}
		printf("%s\n",flag==1?"YES":"NO");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int n, m, M = 1e9 + 7;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(m, 1));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) {
            char c;
            cin >> c;
            if (c == '#') {
                g[i][j] = 0;
                continue;
            }
            if (i && !j) g[i][j] = g[i - 1][j];
            if (!i && j) g[i][j] = g[i][j - 1];
            if (i && j) g[i][j] = (g[i - 1][j] + g[i][j - 1]) % M;
        }
    cout << g[n - 1][m - 1] << '\n';

    return 0;
}

Measured memory_bytes: 4224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define EPS 1e-10

double add(double a,double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
typedef struct Vec{
	double x,y;
	Vec(){}
	Vec( double x,double y):x(x),y(y){}
	Vec operator +(Vec v){return Vec(add(x,v.x),add(y,v.y));}
	Vec operator -(Vec v){return Vec(add(x,-v.x),add(y,-v.y));}
	Vec operator *(double d){return Vec(x*d,y*d);}
	double dot(Vec v){return add(x*v.x,y*v.y);}
	double det(Vec v){return add(x*v.y,-y*v.x);}
}V;


bool on_seg(Vec p1,Vec p2,Vec q)
{
	return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;
}

Vec intersection(Vec p1,Vec p2,Vec q1,Vec q2)
{
	return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
}

Vec A,B;
int N,p=1,c=0;
Vec pos[3];

void check(Vec f,Vec e)
{
	if((B-A).det(e-f)!=0)
	{
		Vec r=intersection(A,B,f,e);
		if(on_seg(A,B,r)&&on_seg(f,e,r))
		{
			c++;
		}
	}
}

int main()
{
	int N;
	scanf("%d",&N);
	for(;N--;)
	{
		c=0;
		for(int i=0;i<3;i++)
			scanf("%lf%lf",&pos[i].x,&pos[i].y);
		scanf("%lf%lf",&A.x,&A.y);
		scanf("%lf%lf",&B.x,&B.y);
		for(int i=0;i<3;i++)
			check(pos[i],pos[(i+1)%3]);
		puts(c==1?"OK":"NG");
	}
}

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

const int INF = 1 << 28;
int N, M;
queue < int > que;
vector < int > graph[200005];
int mc[200005];
int main()
{


  fill_n(mc, 200005, INF);
  mc[0] = 0;
  
  cin >> N >> M;

  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b; --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  que.push(0);
  while(!que.empty()) {
    int v = que.front(); que.pop();
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i];
      if(mc[u] == INF) {
	mc[u] = mc[v] + 1;
	que.push(u);
      }
    }
  }

  if(mc[N - 1] <= 2) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return (0);
}


Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string s[3];
    rep(i,3)cin >>s[i];

    rep(i,3){
        char x=(s[i].at(0)-32);
        cout << x;
    }
    cout << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,s;
  cin >> n >> k >> s;
  int a[s]={0};
  vector<int> b(n,k);
  int count=0;
  for(int i=0;i<s;i++){
    cin >> a[i];
    b[a[i]-1]++;
    count++;
  }
  for(int i=0;i<n;i++){
    b[i]-=count;
    if(b[i]>0)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

  

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);
#define Accepted 0
using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1);
int T, cases, n, m;

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e - a <= k)puts("Yay!");
    else puts(":(");
    return Accepted;
}


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

int main() {
  int n;
  cin >> n;
  int a[n], m[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[i] = a[i];
  }
  sort(m, m + n);
  for (int i = 0; i < n; i++) {
    if (a[i] != m[n - 1]) {
      cout << m[n - 1] << endl;
    } else {
      cout << m[n - 2] << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
//動画解答写し(別解) 
int main(){
  long long n;
  cin>>n;
  string ans;
  while(n){
    n--;
    ans+='a'+n%26;
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]+a[i+1]>b[i]:
    cnt+=b[i]
    a[i+1]=min(a[i+1],a[i]+a[i+1]-b[i])
  else:
    cnt+=a[i+1]+a[i]
    a[i+1]=0
print(cnt)

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

using namespace std;

typedef long long ll;

void rec()
{
}

int main()
{
    ll N;
    ll A[300000];
    ll plus[300000] = {};
    ll minus[300000] = {};
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        if (!(i - A[i] < 1))
        {
            minus[i - A[i]]++;
        }
        if (!(i + A[i] > N))
        {
            plus[i + A[i]]++;
        }
    }
    ll sum = 0;
    for (int i = 1; i <= N; i++)
    {
        sum += plus[i] * minus[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 9892
import math
a,b,h,m = map(int,input().split())

thm = m/60 * 2* math.pi 
thh = (h*60 +  m)/720 * 2* math.pi


xm = b * math.cos(thm)
xh = a * math.cos(thh)

ym = b* math.sin(thm)
yh = a* math.sin(thh)

l=math.sqrt((xm-xh)**2 + (ym-yh)**2)
print(l)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
#define pb push_back

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

/*
string s;
vector<char> ops({'+', '-', '*', '.', '.'});
map<char, int> rank;

int64 calc(int64 l, int64 r);
int64 expr(const string& s, int& p);
int64 number(const string& s, int& p);

int64 expr(const string& s, int& p, int rank = 0) {
    int64 now = 0;
    while (p != s.size()) {
        if (s[p] == '(') {
            p++;
            now = expr(s, p, 0);
            p++;
        }
    }
}

int main(void){
    cin >> s;
    sort(all(ops));
    int64 res = -INF_LL;
    do {
        int cnt = 0;
        REP(i, ops.size()) {
            if (ops[i] == '.') cnt++;
            else rank[ops[i]] = cnt;
        }
        int p = 0;
        expr(s, p, 0);
    }while(next_permutation(all(ops)));
}
*/


struct UnionFind{
  vector<int32> par;

  UnionFind(int32 n){
      REP(i,n){
          par.pb(-1);
      }
  }

  int32 root(int32 x){
      if(par[x] == -1)return x;
      return par[x] = root(par[x]);
  }

  void unite(int32 a, int32 b){
      a = root(a);
      b = root(b);
      par[a] = b;
      return;
  }

  bool same(int32 x, int32 b){
    return root(x) == root(b);
  }
};

int main(void){
    int32 n,m;
    while(cin >> n >> m && n && m){
        using T = tuple<int64, int64, int64>;
        UnionFind uf(n);
        vector<T> edges;
        REP(i,m){
            int32 s,t,c;
            cin >> s >> t >> c;s--;t--;
            edges.emplace_back(c,s,t);
        }
        sort(all(edges));
        int32 cntEdge = 0;
        REP(i,m){
            int32 c,s,t;
            tie(c,s,t) = edges[i];
            if(!uf.same(s,t)){
                uf.unite(s,t);
                cntEdge++;
                if(cntEdge == n / 2){
                    cout << c << endl;
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
#define rep(i,n) for ( int i =0; i < n ; i ++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
int main(){
  ll k;
  string s;
  cin>>s >>k;
  int keta = 0;
  rep(i,s.length()){
    if(s[i]!='1'){   
      keta =i;
      break;
    }
  }
  if(k-1>=keta){
    cout<<s[keta]<<endl;
  }
  else{
    cout << 1 << endl;  
  }
    
  
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
using namespace std;

//fixed << setprecision(10)
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a,int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

map<int, int> prime;
void Prime(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}

int main() {
	double  a, b, x;
	double s;
	cin >> a >> b >> x;
	double ans;
	double t;

	if (2 * x >= a* a* b) {
		s = 2.0 * (a * a * b - x) / a;
		t = s / (a * a);
	}
	else {
		s = x / a;
		t = (b * b) / s;
		t /= 2.0;
	}
	ans = atan(t) * 180.0 / PI;
	cout << fixed << setprecision(10);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int x,y,book[12];
    scanf("%d%d",&x,&y);
	if(x==2)
		book[x]=3;
	else if(x==4||x==6||x==9||x==11)
		book[x]=2;
	else
		book[x]=1;
	if(y==2)
		book[y]=3;
	else if(y==4||y==6||y==9||y==11)
		book[y]=2;
	else
		book[y]=1;
	if(book[x]==book[y])
		printf("Yes");
	else
		printf("No");
	return 0;
}



Measured memory_bytes: 128
c = (1..3).map do
  gets.chomp.split.map(&:to_i)
end

x = (0..1).map do |i|
      (0..1).map do |j|
        c[i + 1][j] - c[i][j] == c[i + 1][j + 1] - c[i][j + 1]
      end.all?
    end.all?

y = (0..1).map do |i|
      (0..1).map do |j|
        c[j + 1][i] - c[j][i] == c[j + 1][i + 1] - c[j][i + 1]
      end.all?
    end.all?

puts x && y ? :Yes : :No

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int[] a=sc.Ia;
		Array.Sort(a);
		int lb=-1,ub=s[0],mid=0;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			bool q=false;
			if(a[mid]>=s[1]){q=true;}
			else{
				bool[] dp=new bool[s[1]+1];
				dp[0]=true;
				for(int j=0;j<s[0];j++){
					if(j!=mid){
						for(int k=s[1];k>=a[j];k--){
							if(dp[k-a[j]]){dp[k]=true;}
						}
					}
				}
				for(int j=s[1]-a[mid];j<s[1];j++){
					if(dp[j]){q=true;break;}
				}
			}
			if(q){ub=mid;}
			else{lb=mid;}
		}
		Console.WriteLine("{0}",ub);
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    map<ll,int> ma;
    rep(i,n){
        int a; cin >> a;
        ma[-a]++;
    }
    vector<ll> big;
    ll ans = 0;
    auto itr = ma.begin();
    if(itr->second >= 4){
        ans = itr->first * itr->first;
        cout << ans << endl;
        return 0;
    }
    for(auto elem : ma){
        ll key = -1 * elem.first;
        int value = elem.second;
        if(value >= 2) big.push_back(key);
        if(big.size() == 2) break;
    }
    if(big.size() < 2){
        cout << 0 << endl;
        return 0;
    }
    ans = big[0] * big[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<numeric>

using namespace std;

long long inv(long long n) {
	if (n == 1)return 1;
	long long mod = 1000000007;
	return mod - inv(mod%n)*(mod / n) % mod;
}

int main() {
	int mod = 1000000007;
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	if ((w - b) < (h - a)) {
		int tmp = h;
		h = w;
		w = tmp;
		tmp = a;
		a = b;
		b = tmp;
	}
	//Σ_[i=0,...,(h-a-1)] (C[b+h-a-1,i]*C[w-b+a-1,(w-b)-(h-a)+i])
	int maxval = max(b + h - a - 1, w - b + a - 1);
	int minval = min(b + h - a - 1, w - b + a - 1);
	long long factmax = 1;
	long long factmin;
	for (int i = 1; i <= maxval; i++) {
		factmax *= i;
		factmax %= mod;
		if (i == minval) factmin = factmax;
	}
	// factmaxの逆元を計算する
	vector<long long> invfact(maxval+ 1);
	invfact[maxval] = inv(factmax);
	for (int i = maxval ; i > 0; i--) {
		invfact[i-1] = (i*invfact[i]) % mod;
	}
	long long den = 0;
	long long tmp;
	for (int i = 0; i < h - a; i++) {
		tmp = invfact[i];
		tmp *= invfact[b + h - a - 1 - i];
		tmp %= mod;
		tmp *= invfact[(w - b) - (h - a) + i];
		tmp %= mod;
		tmp *= invfact[h - i - 1];
		tmp %= mod;
		den += tmp;
		den %= mod;
	}
	
	cout << (((factmax*factmin)%mod)*den) % mod << endl;
	return 0;
}

Measured memory_bytes: 1536
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X,string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 
cout<<lcs<<"\n";
// Print the lcs 
//cout << "LCS of " << X << " and " << Y << " is " << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
string X,Y;
cin>>X>>Y;
int m = X.size(); 
int n = Y.size(); 
lcs(X, Y, m, n); 
return 0; 
} 


Measured memory_bytes: 35456
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int task[3];
    for(int i = 0; i < 3; i++){
        cin >> task[i];
    }
    bool flag = false;
    int cache;
    while(1){
        flag = false;
        for(int i = 0; i < 2; i++){
            if(task[i] > task[i+1]){
                cache = task[i];
                task[i] = task[i+1];
                task[i+1] = cache;
                flag = true;
            }
        }
        if(!flag){
            break;
        }
    }
    cout << (abs(task[1] - task[0]) + abs(task[2] - task[1]));
}

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

int main()
{
	int n;
	cin >> n;
	vector<long long> v(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	long long result = 0;
	long long maxim = v[0];
	for (int i = 1; i < n; i++)
	{
		maxim = max(maxim, v[i]);
		result += maxim - v[i];
		//cout << maxim - v[i] << " ";
	}
	cout << result;
}


Measured memory_bytes: 4744
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#define _USE_MATH_DEFINES
#define LL long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;

int smax(int *ary) {
	int m = 0;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (m < ary[i]) m = ary[i];
	return m;
}

int nmax(int *ary) {
	int max = 0, num;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) {
			max = ary[i];
			num = i;
		}
	return max, num;
}

int main() {
	int cnt = 0, size;
	string s, con;
	cin >> s;
	size = s.size();
	s[s.size()-1] = '\0';
	for (int i = 2,j=1; i <= s.size(); i++) {
		size --;
		if (size % 2 == 0) {
			if (s.substr(0, size / 2) == s.substr(size / 2, size/2)) {
				cout << s.size()-j << endl;
				return 0;
			}
		}
		s[s.size() - i] = '\0';
		j++;
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 256