akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include<unistd.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N;
    cin >> N;
    sleep(1);
    if(N % 2 == 0)cout << N << endl;
    else cout << 2 * N << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] height = new int[num];
		
		for (int i = 0; i < num; i++) {
			height[i] = scan.nextInt();
		}
		
		int count = 1;
		int highest = height[0];
		for (int i = 1; i < num; i++) {
			if (highest <= height[i]) {
				highest = height[i];
				count++;
			}
		}
		
		System.out.println(count);
		scan.close();
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <complex>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long double n, x = 1, y = 0;
	cin >> n;
	//cout<<cos(3.14159265358979/180*n);
	//cout<<sin(3.14159265358979/180*n);
	long double a, b, c, d;
	a = cos(3.14159265358979 / 180 * n);
	b = sin(3.14159265358979 / 180 * -1 * n);
	c = sin(3.14159265358979 / 180 * n);
	d = a;
	for (int i = 0; i < 376; i++) {
		long double xx, yy;
		xx = a * x + b * y;
		yy = c * x + d * y;
		x = xx;
		y = yy;
		if (abs(y) <= 10e-5) {
			if ((x >= 0.9999) && (x <= 1.0001)) {
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

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

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int A, B, C; cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);
    cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 256
from collections import deque


def main():
    S = input()
    que = deque(S)
    Q = int(input())
    reverse = False
    for _ in range(Q):
        query = input()
        if len(query) == 1:
            reverse = not reverse
        else:
            _, F, C = query.split()
            if (not reverse and F == '1') or (reverse and F == '2'):
                que.appendleft(C)
            else:
                que.append(C)
    if reverse:
        que.reverse()
    print(''.join([c for c in que]))


if __name__ == '__main__':
    main()


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		long long n,a,b;
		cin >> n >> a >> b;
		if(a > b)swap(a, b);
		if(((b- a)%2) == 0){
			cout << (b-a)/2 << "\n";
		}
		else{
			long long ret0 = 0, ret1;
			{
				ret0 = a + (b-a-1)/2;
			}
			{
				ret1 = n-b+1+(-a+b-1)/2;
			}
			cout << min(ret0, ret1) << "\n";
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main() {
    int N, K;
    cin >> N;
    
    for (int i=0;i<=14;i++) {
        int temp_N = N - 7*i;
        if (temp_N<0) {
            cout << "No" << endl;
            break;
        }
        if (temp_N%4==0){
            cout << "Yes" << endl;
            break;
        }
    }
}

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

int main(){
  
  string S, T;
  cin >> S >> T;
  int cnt=0, i;
  
  for(i=0;i<S.size();i++){
    if(S[i]!=T[i]) cnt++;
  }
  cout << cnt << endl; 
  return 0;
}


Measured memory_bytes: 3848
#include <iostream>

using namespace std;

int main()
{
int k,even ,odd,counter;
 cin>>k;
if(k>=2&&k<=100){
if(k%2==0)
        {
    even=k/2;
    odd=even;
     counter=even*odd;


}    else
        even=k/2;
        odd=k-even;
        counter=even*odd;


}
cout<<counter;
}

Measured memory_bytes: 256
import math

a,b,x = list(map(int, input().strip().split()))
h = x/a/a
if h < b/2:
	aa = 2*x/a/b
	ans = math.atan2(aa, b) * 180 / math.pi
else:
	bb = 2*(a*a*b - x)/a/a
	ans = math.atan2(a, bb) * 180 / math.pi
print(90 - ans)

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    string S;
    int x = 0, y = 0;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
        if ((i % 2 == 0 && S[i] == '0') || (i % 2 == 1 && S[i] == '1'))
            x++;
    for (int i = 0; i < S.size(); i++)
        if ((i % 2 == 0 && S[i] == '1') || (i % 2 == 1 && S[i] == '0'))
            y++;
    cout << min(x, y);
}

Measured memory_bytes: 512
from bisect import bisect


def sieve(n):
    prime = [True] * n
    prime[0] = prime[1] = False
    for i in xrange(2, int(n ** 0.5) + 1):
        if prime[i]:
            for j in range(i * i, n, i):
                prime[j] = False
    return [i for i in xrange(2, n) if prime[i]]

primes = sieve(999999)
while 1:
    try:
        print bisect(primes, input())
    except:
        break

Measured memory_bytes: 27992
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  ll ans=0;
  ll ma=p[0];
  repo(i,n){
    if(ma>p[i]) ans+=ma-p[i];
    chmax(ma,p[i]);
  }






  cout << ans<< endl;

}

Measured memory_bytes: 4780
Public Class Program
  Shared Sub Main()
    Dim abx As Double() = Array.ConvertAll(Of String, Double)(Console.ReadLine().Split(" "), AddressOf Double.Parse)
    Dim a As Double = abx(0)
    Dim b As Double = abx(1)
    Dim x As Double = abx(2)
    Dim tan As Double = If(x < a * a * b / 2, a * b * b / (2 * x), 2 * (a * a * b - x) / (a * a * a))
    Console.WriteLine(Math.Atan(tan) * 180 / Math.PI)
  End Sub
End Class

Measured memory_bytes: 11092
import math

def C(n, r):
	fact = math.factorial
	return fact(n) // fact(r) // fact(n-r)

N, A, B = map(int, input().split())
v = list(map(int, input().split()))

v_sort = sorted(v, reverse=True)

print(sum(v_sort[:A])/A)

a, b = v_sort.count(v_sort[A-1]), v_sort[:A].count(v_sort[A-1])

if v_sort[0] == v_sort[A-1]:
	print(sum([C(a, r) for r in range(A, min(B, a)+1)]))
else:
	print(C(a, b))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  vector<int> a(5);
  REP(i,5) cin >> a[i];
  int k;
  cin >> k;
  
  bool f = true;
  REP(i, 4){
    FOR(j, i+1, 5)
    f &= (a[j] - a[i] <= k);
  }

  cout << (f ? "Yay!" : ":(") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    ll q;
    cin >> s >> q;
    int count_of_reverse = 0;
    string left,right;
    deque<char>answer;
    REP(i,s.length())answer.push_back(s[i]);
    int is_reversed = 0;
    REP(i,q){
        int t;
        cin >> t;
        
        if(t == 1){
            is_reversed = is_reversed^1;
            count_of_reverse++;
        }
        if(t == 2){
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(is_reversed==0)
                    answer.push_front(c);
                else
                    answer.push_back(c);
            }
            if(f == 2){
                if(is_reversed == 0)
                    answer.push_back(c);
                else
                    answer.push_front(c);
            }
        }
    }
    //string answer = left+s+right;
    if(count_of_reverse%2){
        reverse(ALL(answer));
    }
    
    REP(i,answer.size())cout << answer[i];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 896
#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;
}
double Distance(pair<double, double> a, pair<double, double> b) {
  return sqrt(pow(b.first - a.first, 2) + pow(b.second - a.second, 2));
}

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double t = H * 60 + M;
  double oa = 2 * M_PI / 720;
  double ob = 2 * M_PI / 60;
  pair<double, double> a = {A*cosf64(oa * t), A*sinf64(oa * t)};
  pair<double, double> b = {B*cosf64(ob * t), B*sinf64(ob * t)};
  printf("%.20lf\n", Distance(a, b));

  return 0;
}


Measured memory_bytes: 4232
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

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

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

template<class T> void print(vector<T>& a){
    int sz = a.size();
    for(int i=0;i<sz;i++)cout<<a[i] << (i<sz-1?' ':'\n');
}

template<class T> bool chmin(T& a,T b){
    if(a > b){ a = b; return true; } return false;
}
template<class T> bool chmax(T& a,T b){
    if(a < b){ a = b; return true; } return false;
}
/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 998244353;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int64_t n,s;cin >> n >> s;
    vector<int64_t> a(n);rep(i,n)cin >> a[i];

    vector<mint> dp(3010,0);
    mint ans = 0;
    rep(i,n){
        dp[0] += 1;
        vector<mint> tmp = dp;
        for(int j = s + 1 - a[i];j >= 0;j--) dp[j + a[i]] += tmp[j];
        ans += dp[s];
    }
    cout << ans << '\n';
}

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

int main(){
    int i;
    long long n, a[5], t = 0, m = 9999999999999999;
    cin >> n;
    for(i=0; i<5; i++){
        cin >> a[i];
    }
    for(i=0; i<5; i++){
        if(m > a[i]){
            t = (n-1)/a[i]+1+i;
            m = a[i];
        }else{
            t += 1;
        }
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n;
    cin>>m>>n;
    int cnt=0;
    for(int i=m;i<=n;i++){
    	string s=to_string(i);
    	string s1=s;
    	reverse(s.begin(),s.end());
    	if(s1==s){
    		cnt++;
    	}
    }
    cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
using namespace std;
typedef long long ll;

ll const MAX = 2005;
vector<ll> g[MAX];
bool ex[MAX];

bool dfs(vector<long long>& num, vector<ll>& dist, vector<ll>& point, vector<bool>& visited, ll cur, ll i){
    visited[cur] = 1;
    for(ll nx: g[cur]){
        if(visited[nx]){
            continue;
        }
        dfs(num, dist, point, visited, nx, i);
        
        dist[nx] += num[nx];
        ll dn = dist[nx], dc = dist[cur], pn = point[nx], pc = point[cur];
        if(dist[nx] < dist[cur]){
            swap(dn, dc);
            swap(pn, pc);
        }
        point[cur] = dc * 2 + min(dn - dc, pn) / 2 * 2;
        num[cur] += num[nx];
        dist[cur] += dist[nx];
    }
    num[cur] += ex[cur];
    return (dist[cur] == point[cur]);
}

ll f(ll n,ll i){
    vector<long long> num(MAX, 0), dist(MAX, 0), point(MAX,0);
    vector<bool> visited(MAX, 0);
    if(dfs(num, dist, point, visited, i, i)){
        return point[i] / 2;
    }else{
        return 1e18;
    }
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    REP(i,1,n-1){
        ll a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    REP(i,1,n){
        ex[i] = (s[i-1] == '1');
    }
    ll ans = 1e18;
    REP(i,1,n){
        ans = min(ans, f(n, i));
    }   
    if(ans == 1e18){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

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

// output
#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
// utility
#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 T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#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;


signed main() {
  int H, W, K; 
  cin >> H >> W >> K;

  vector<vector<int>> dp(H+1, vector<int>(W, 0));
  dp[0][0] = 1;

  REP(i, H){
    REP(bit, (1<<(W-1))){
      bool flag = true;
      REP(j, W-2){
        if((bit >> j)&1 && (bit >> (j+1))&1) flag = false;
      }
      if(!flag) continue;

      REP(j, W){
        if(j != 0 && (bit >> (j-1))&1) {
          (dp[i+1][j-1] += dp[i][j]) %= MOD;
        }else if(j != W-1 && (bit >> j)&1){
          (dp[i+1][j+1] += dp[i][j]) %= MOD;
        }else{
          (dp[i+1][j] += dp[i][j]) %= MOD;
        }
      }
    }
  }

  cout << dp[H][K-1] << endl;

  return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 110;

int n;
int a[N];
LL res;

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

    for(int i = 0; i < n; i++)
        for(int j = 0; j < i; j++)
            res += a[i] * a[j];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num


print(int(list(map(search_divisor_num,list(range(1,N + 1))[:: 2])).count(8)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 100005
vector<int> G[N];
int f[N],n,k,ans=0;
int dep[N];
void dfs(int u)
{
	dep[u]=0;
	for(int v:G[u])
	{
		dfs(v);
		dep[u]=max(dep[u],dep[v]);
	}
	dep[u]++;
	if(dep[u]==k&&u!=1&&f[u]!=1) dep[u]=0,ans++;
}
signed main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) f[i]=read();
	if(f[1]!=1) ans++,f[1]=1;
	for(int i=2;i<=n;i++) G[f[i]].pb(i);
	dfs(1);
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 16144
#　解説確認後AC
#　参考ブログ「けんちょんの競プロ精進記録」
#　URL https://drken1215.hatenablog.com/entry/2019/06/15/135300

N,M = map(int,input().split())
s = []
for i in range(M):
    s.append(list(map(int,input().split()))) # 各電球に繋がっているスイッチを格納
    s[i].pop(0) # 先頭要素はスイッチの数なので削除
p = list(map(int,input().split()))

res = 0

for bit in range(1<<N): # bit全探索 O(2**N)
    ok = True
    for i in range(M):
        con = 0
        for v in s[i]: # i個目の電球に繋がっているスイッチの数だけループ
            if bit & (1<<(v-1)): con += 1 # スイッチvがONならカウント+1
        if con % 2 != p[i]: ok = False # 電球が点灯する条件になっているか
    if ok: res += 1 # 電球が全て点灯しているならカウント+1
print(res)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int n, arr[MAXN+10], dp[MAXN+10];

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i, j;

    scanf("%d", &n);
    for(i=1; i<=n; i++) scanf("%d", &arr[i]);

    dp[1]=0; dp[2]=abs(arr[1]-arr[2]);
    for(i=3; i<=n; i++) dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]), dp[i-1]+abs(arr[i]-arr[i-1]));

    printf("%d", dp[n]);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

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

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

Measured memory_bytes: 3632
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        for(int i=0;i<c.length;i++){
          	System.out.print(c[i] == '?' ? 'D' : c[i]);
        }
    }
}

Measured memory_bytes: 47288
# -*- coding: utf-8 -*-
# template: v1.3.1

# 丸太の分割分割問題。
# 速度の観点から、「答えの二分探索」が必要。典型らしい。



import io
import sys
import math

### DEBUG ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
2 1
1 50
"""

# Worst
# _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }"
# _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }"


_EXPECTED = """\
ABC
"""
if _DEB:
    sys.stdin = io.StringIO(_INPUT)
    print("!! Debug Mode !!")


def logd(str):
    if _DEB: print(f"[deb] {str}")

# is_m_OK?
def f(m):
    cut=0
    for aa in a:
        c=math.ceil(aa/m)
        cut+=c-1
        if cut > k:
            return False
    return True
#m=7,a=[7,9]


### INPUT ####
n,k = map(int, input().split())
a = list(map(int, input().split()))

### Solve ####
def solve():
    # Process

    ans=0
    l,r=0,10**9
    while abs(r-l)!=1:
        m=(l+r)//2
        if f(m): # m is ok: Go left
            r=m
        else: # m is ng : Go right
            l=m
    
    ans=r
    # ans=min(r,max(a))

    # OUPUT
    ans = str(ans)
    print(ans)
    return ans

### MAIN ###
if __name__ == "__main__":
    ans = solve()

    # Checker
    if _DEB:
        if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!")
        else: print(f"\n!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 31084
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,a[110],ans=(1e9),s1,s2;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=100;i++) {
		s1=s2=0;
		for (int j=1;j<=n;j++)
			if (j<=i) s1+=a[j];
			else s2+=a[j];
		ans=min(ans,abs(s1-s2));
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;
    map<string, int> mp;
    string s;

    while (n--) {
        cin >> s;
        ++mp[s];
    }
    vector<string> v = {"AC", "WA", "TLE", "RE"};
    for (auto i : v) {
        cout << i << " x " << mp[i] << '\n';
    }


}

Measured memory_bytes: 3632
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


o = read_str()
e = read_str()
if len(e) < len(o):
    e = e + ' '
l = []
for i, j in zip(o, e):
    l.append(i)
    l.append(j)
res = ''.join(l)
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define INF 99999999
#define M 1000000007
#define x first
#define y second

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

int main(){
	int n,a[10001];
	cin >> n;
	rep(i,n) cin >> a[i];
	int ans = 0;
	rep(i,n){
		int cnt = 0;
		while(!(a[i]%2)){
			cnt++;
			a[i] /= 2;
		}
		ans += cnt;
	}
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var n = ReadLong();
		var s = "";

		while (true) {
			n--;
			var t = n % 26;
			s = (char)(t + 'a') + s;
			if (n <= 25) break;
			n = n / 26;
		}

		Console.WriteLine(s);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


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

const int MAX = 1e5 + 5;
int dp[MAX];

int main() {

  int n;
  int h[100005];

  cin >> n;

  for ( int i = 1; i <= n; ++i ) {
    cin >> h[i];
  }

  dp[0] = 1e9;

  for ( int i = 2; i <= n; ++i ) {
    // absは絶対値
    dp[i] = min ( dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]) );
  }

  cout << dp[n] << endl;

  return 0;

}


// source109.cpp
// Atcoder Educational DP Contest / DP まとめコンテスト [A - Frog 1]

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[5];
int main() {
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    sort (a,a+3);
    if (a[0]==5&&a[1]==5&&a[2]==7) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int main(){

  int N;
  string s;
  cin >> N;
  cin >> s;

  vector<vector<long long>> cnt(N, vector<long long>(N + 1, 0));

  cnt[0][0] = 0;
  for(int i = 1; i <= N; i++){
    cnt[0][i] = cnt[0][i - 1] + 1;
  }

  for(int i = 1; i < N; i++){
    cnt[i][0] = 0;
    for(int j = 1; j <= N - i; j++){
      long long value = 0;
      if(s[i - 1] == '>'){
	value = (cnt[i - 1][N - i + 1] - cnt[i - 1][j] + MOD) % MOD;
      }
      else{
	value = cnt[i - 1][j];
      }

      cnt[i][j] = (cnt[i][j - 1] + value) % MOD;
    }
  }

  cout << cnt[N - 1][1] << endl;

  return 0;
}


Measured memory_bytes: 70656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int w, h;
  while(cin>>w>>h,w||h) {
    ll dp[100][100][2]; // (x,y)???????????????????????¨?????????????????????????????°
    CLR(dp);
    // 0 - > ????????? 1 - > ?????????
    dp[0][0][0] = dp[0][0][1] = 1;
    FOR(x,0,w) {
      FOR(y,0,h) {
        if(!x && !y) continue;
        if(x == 0) {
          dp[x][y][0] = dp[x][y-1][0];
        } else if (y == 0) {
          dp[x][y][1] = dp[x-1][y][1];
        } else {
          // ?????????
          dp[x][y][0] = (dp[x][y-1][0] + dp[x-1][y-1][1]) % 100000;
          // ?????????
          dp[x][y][1] = (dp[x-1][y][1] + dp[x-1][y-1][0]) % 100000;
        }
      }
    }
    cout << (dp[w-1][h-1][0] + dp[w-1][h-1][1]) % 100000 << endl;
  }
  return 0;
}

Measured memory_bytes: 3224
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static boolean[][] domino = new boolean[7][7];
	static int[] count = new int[7];
	static int N;

	public static void main(String[] args) throws Exception {
		while (sc.hasNext()) {
			N = sc.nextInt();
			for (boolean[] a : domino) {
				Arrays.fill(a, false);
			}
			Arrays.fill(count, 0);
			for (int i = 0; i < N; ++i) {
				String v = sc.next();
				int f = v.charAt(0) - '0';
				int s = v.charAt(1) - '0';
				domino[f][s] = true;
				++count[f];
				++count[s];
			}
			System.out.println(solve() ? "Yes" : "No");
		}
	}

	static boolean solve() {
		for (int i = 0; i < 7; ++i) {
			if (solve(i, 0)) {
				return true;
			}
		}
		return false;
	}

	static boolean solve(int first, int depth) {
		if (depth == N) return true;
		if (count[first] == 0) return false;
		int odd = 0;
		for (int i = 0; i < 7; ++i) {
			if (count[i] % 2 != 0) ++odd;
		}
		if (!(odd == 0 || (odd == 2 && count[first] % 2 != 0))) return false;
		for (int i = 0; i < 7; ++i) {
			int r = Math.min(i, first);
			int c = Math.max(i, first);
			if (domino[r][c]) {
				domino[r][c] = false;
				--count[r];
				--count[c];
//				System.out.println(r + " " + c + " " + depth);
				if (solve(i, depth + 1)) return true;
				++count[c];
				++count[r];
				domino[r][c] = true;
			}
		}
		return false;
	}
}

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

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) {cout<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}


typedef long long int64;


int main() {
    int n,m;
    cin >> n >> m;
    cout << (n==m? "Yes" : "No") << endl;
}

Measured memory_bytes: 888
import Control.Monad
f c = map (\x -> if x == '?' then c else x)
g t s
  | x /= y || x == EQ || y == EQ = (0,1)
  | x == LT = (0,0)
  | x == GT = (1,0)
  where
    x = t `compare` f 'a' s
    y = t `compare` f 'z' s
h (a,b) (c,d) = (a+c,b+d)
main = do
  n <- readLn
  ss <- replicateM n getLine
  t <- getLine
  let (x,y) = foldl1 h $ map (g t) ss
  putStrLn $ unwords $ map show [x+1..x+y+1]

Measured memory_bytes: 6780
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,m;
    while(cin>>n>>m&&n&&m){
        vector<int> v(100,0);
        rep(i,0,n){
            int x; cin>>x;
            rep(j,0,x){
                int t; cin>>t; t--;
                v[t]++;
            }
        }
        int ans=0,num=-1;
        rep(i,0,100){
            if(v[i]>=m && num<v[i]){
                num=v[i];
                ans=i+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll h=in(),w=in();
    if(h==1||w==1){
        cout<<1<<endl;
    }else{
        cout<<(h*w+1)/2<<endl;
    }
}


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

using namespace std;

const int MAX_SIZE = 310;

#define pb push_back

vector<int> arr[MAX_SIZE];

vector<bool> deleted(MAX_SIZE);

vector<int> taken[MAX_SIZE];

void delUpd(int x)
{
	int i = 0;
	while(deleted[arr[x][i]] == true) i++;
	taken[arr[x][i]].pb(x);
}

int main()
{
	int n, m;
	cin >> n >> m;
	int x;
	for(int i = 1; i <= m; i++)
		deleted[i] = false;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> x;
			arr[i].pb(x);
		}
	}
	int ans = 1000;
	if(m == 1)
	{
		cout << n << endl;
		return 0;
	}
	for(int j = 1; j <= n; j++)
	{
		delUpd(j);
	}
	for(int i = 1; i < m; i++)
	{
		int next, mm = 0;
		for(int j = 1; j <= m; j++)
		{
			if(taken[j].size() > mm)
			{
				mm = taken[j].size();
				next = j;
			}
		}
		ans = min(ans, mm);
		deleted[next] = true;
		for(auto &j: taken[next])
		{
			delUpd(j);
		}
		taken[next].clear();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		int x=0,y=0;
		int co=0;
		while(co!=20000){
			if(in[x][y]=='>')y++;
			else if(in[x][y]=='<')y--;
			else if(in[x][y]=='v')x++;
			else if(in[x][y]=='^')x--;
			else break;
			co++;
		}
		if(co==20000)cout<<"LOOP"<<endl;
		else cout<<y<<" "<<x<<endl;
	}
}

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

int main(){
	int n;
  string s;
  cin >> s;
  n = s.length();
  int cnt1 = 0;
  int cnt0 = 0;

  for(int i = 0; i < n; i++){
    if(s.at(i) == '0'){
      cnt0++;
    }
    else{
      cnt1++;
    }
  }

  int m = min(cnt0, cnt1);

  std::cout << m * 2 << '\n';

}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();

		Map<Integer, Long> mp = new HashMap<Integer, Long> ();
		ArrayList<Integer> al = new ArrayList<Integer> ();
		while(sc.hasNext()) {
			int a = sc.nextInt();
			long t = sc.nextLong();
			if(mp.containsKey(a)) {
				mp.put(a, mp.get(a)+t);
			}
			else {
				mp.put(a, t);
				al.add(a);
			}
		}
		
		Integer[] ar = al.toArray(new Integer[al.size()]);
		Arrays.sort(ar);
		int i = 0;
		long ttl = mp.get(ar[i]);
		while(ttl<k) {
			i++;
			ttl += mp.get(ar[i]);
		}
		System.out.println(ar[i]);
	}
}

Measured memory_bytes: 99116
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;




int main(void) {
  ll N;
  cin >> N;
  ll i, j;
  
  ll cnt[11][11]={};
  for(i=1; i<=N; i++) {
    string s=to_string(i);
    cnt[s[0]-'0'][s[(ll)s.size()-1]-'0']++;
  }
  
  
  ll ans=0;
  for(i=1; i<10; i++) {
    for(j=i; j<10; j++) {
      if(i==j) {
        ll t=cnt[i][j];
        ans+=t*t;
      }else {
        ll s=cnt[i][j];
        ll t=cnt[j][i];
        ans+=s*t*2;
      }
      
    }
  }
  
  pt(ans);
  
  
  
}





Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            long H = long.Parse(lines[0]);
            long W = long.Parse(lines[1]);
            long smax = long.MinValue;
            long smin = long.MaxValue;
            long ans = long.MaxValue;

            for (int i = 1; i < H; i++)
            {
                smax = long.MinValue;
                smin = long.MaxValue;
                smax = Math.Max(smax, i * W);
                smin = Math.Min(smin, i * W);
                if (W % 2 == 0)
                {
                    smax = Math.Max(smax, (H - i) * (W / 2));
                    smin = Math.Min(smin, (H - i) * (W / 2));
                }
                else
                {
                    smax = Math.Max(smax, (H - i) * (W / 2 + 1));
                    smin = Math.Min(smin, (H - i) * (W / 2));
                }
                ans = Math.Min(ans, smax - smin);
            }

            for (int i = 1; i < H; i++)
            {
                smax = long.MinValue;
                smin = long.MaxValue;
                smax = Math.Max(smax, i * W);
                smin = Math.Min(smin, i * W);
                if ((H - i) % 2 == 0)
                {
                    smax = Math.Max(smax, (H - i) / 2 * W);
                    smin = Math.Min(smin, (H - i) / 2 * W);
                }
                else
                {
                    smax = Math.Max(smax, ((H - i) / 2 + 1) * W);
                    smin = Math.Min(smin, (H - i) / 2 * W);
                }
                ans = Math.Min(ans, smax - smin);
            }

            for (int i = 1; i < W; i++)
            {
                smax = long.MinValue;
                smin = long.MaxValue;
                smax = Math.Max(smax, i * H);
                smin = Math.Min(smin, i * H);
                if (H % 2 == 0)
                {
                    smax = Math.Max(smax, (W - i) * (H / 2));
                    smin = Math.Min(smin, (W - i) * (H / 2));
                }
                else
                {
                    smax = Math.Max(smax, (W - i) * (H / 2 + 1));
                    smin = Math.Min(smin, (W - i) * (H / 2));
                }
                ans = Math.Min(ans, smax - smin);
            }

            for (int i = 1; i < W; i++)
            {
                smax = long.MinValue;
                smin = long.MaxValue;
                smax = Math.Max(smax, i * H);
                smin = Math.Min(smin, i * H);
                if ((W - i) % 2 == 0)
                {
                    smax = Math.Max(smax, (W - i) / 2 * H);
                    smin = Math.Min(smin, (W - i) / 2 * H);
                }
                else
                {
                    smax = Math.Max(smax, ((W - i) / 2 + 1) * H);
                    smin = Math.Min(smin, (W - i) / 2 * H);
                }
                ans = Math.Min(ans, smax - smin);
            }

            Console.WriteLine(ans);
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    int A = N / 1000, B = N / 100 % 10, C = N / 10 % 10, D = N % 10;

    if(A+B+C+D == 7) cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<"=7";
    else if(A+B+C-D == 7) cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<"=7";
    else if(A+B-C+D == 7) cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<"=7";
    else if(A-B+C+D == 7) cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<"=7";
    else if(A-B-C+D == 7) cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<"=7";
    else if(A+B-C-D == 7) cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<"=7";
    else if(A-B+C-D == 7) cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<"=7";
    else if(A-B-C-D == 7) cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<"=7";




}

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

using namespace std;

int main(void)
{
	int h;
	int n;
	cin>>h>>n;
	int a[n],i;
	for(i = 0; i < n; i++){
		cin>>a[i];
	}
	
	int sum = 0;
	for(i = 0; i < n; i++){
		sum += a[i];
	}
	if(sum >= h){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using tp = tuple<ll, ll, ll>;

constexpr int mod = 1e9 + 7;
constexpr int wlim = 10, hlim = 100;

ll dp[hlim+1][wlim+1];

ll fib(int n){
  if(n == 0 || n == 1) return 1;
  else return fib(n-1) + fib(n-2);
}

tp calcWeight(int i, int w){
  tp ret {0, 0, 0};

  get<1>(ret) = (fib(i-1) * fib(w-i)) % mod;
  if(i != 1) get<0>(ret) = (fib(i-2) * fib(w-i)) % mod;
  if(i != w) get<2>(ret) = (fib(i-1) * fib(w-i-1)) % mod;
  return ret;
}

int main(){
  int h, w, k; cin >> h >> w >> k;

  dp[0][1] = 1;

  FOR(i, 0, h)FOR(j, 1, w+1){
    tp weight = calcWeight(j, w);
    (dp[i+1][j-1] += (get<0>(weight) * dp[i][j]) % mod) %= mod;
    (dp[i+1][j] += (get<1>(weight) * dp[i][j]) % mod) %= mod;
    (dp[i+1][j+1] += (get<2>(weight) * dp[i][j]) % mod) %= mod;
  }

  cout << dp[h][k] << endl;

  return 0;
}


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

char s[10000];

int main() {
	int n; cin >> n;
	scanf("%s", s);
	int len = strlen(s);
	for(int i = 0; i < len; ++i) {
		s[i] -= 'A';
	}
	for(int i = 0; i < len; ++i) {
		s[i] += n;
		s[i] %= 26;
	}
	for(int i = 0; i < len; ++i) putchar(s[i] + 'A');
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;


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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    ll ans = 0;
    ll tmpA, tmpB, tmpC;
    if(A%2 == 1|| B%2 == 1||C%2 == 1){
        cout << ans << endl;
    }
    else if(A == B && B== C){
        cout << -1 << endl;
    }
    else
    {
        while(A%2 == 0 && B%2 == 0 && C%2 == 0){
            tmpA = B / 2 + C / 2;
            tmpC = A / 2 + B / 2;
            tmpB = C / 2 + A / 2;
            A = tmpA;
            B = tmpB;
            C = tmpC;
            ans++;
        }
        cout << ans << endl;

    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  if(b=='T')cout<<'A'<<endl;
  if(b=='C')cout<<'G'<<endl;
  if(b=='G')cout<<'C'<<endl;
}


Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
char a , b ;
cin >> a >> b ;
if ( a == '9' || b == '9' )cout <<"Yes";
else cout << "No";

return 0 ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int n, k, q;
    static int[] a;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        q = sc.nextInt();
        a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        int ans = Integer.MAX_VALUE;
        for(int i=0; i<n; i++){
            int y = a[i];
            int x = calcMax(y);
            if(x > 0){
                ans = Math.min(ans, x-y);
            }
        }

        System.out.println(ans);
    }

    public static int calcMax(int min){
        int max = 0;
        ArrayList<Integer> all = new ArrayList<Integer>();
        ArrayList<Integer> cont = new ArrayList<Integer>();
        for(int i=0; i<n; i++){
            if(a[i] >= min){
                cont.add(a[i]);
            }else{
                if(cont.size() >= k){
                    Collections.sort(cont);
                    for(int j=0; j<cont.size()-k+1; j++){
                        all.add(cont.get(j));
                    }
                }
                cont.clear();
            }
        }
        if(cont.size() >= k){
            Collections.sort(cont);
            for(int j=0; j<cont.size()-k+1; j++){
                all.add(cont.get(j));
            }
        }

        if(all.size() >= q){
            Collections.sort(all);
            max = all.get(q-1);
        }else{
            max = -1;
        }
        return max;
    }
}

Measured memory_bytes: 87600