akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Deque<String> a = new ArrayDeque<>();
        Deque<String> b = new ArrayDeque<>();
        Deque<String> c = new ArrayDeque<>();
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            a.add(s.substring(i, i + 1));
        }
        s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            b.add(s.substring(i, i + 1));
        }
        s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            c.add(s.substring(i, i + 1));
        }
        sc.close();
        String card = a.poll();
        while (true) {
            if ("a".equals(card)) {
                if (a.size() == 0) {
                    System.out.println("A");
                    return;
                }
                card = a.poll();
            } else if ("b".equals(card)) {
                if (b.size() == 0) {
                    System.out.println("B");
                    return;
                }
                card = b.poll();
            } else {
                if (c.size() == 0) {
                    System.out.println("C");
                    return;
                }
                card = c.poll();
            }
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=b) cout << "Yes" << endl;
  else if(a>=c&&c>=b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string T; 
    cin >> T;

    ll N =T.length();

    REP(i, N){
        if(T[i] == '?'){
            T[i] = 'D';
        }
    }
    cout << T << endl;
    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main(){
    int h, m, h2, m2, k;

    cin >> h >> m >> h2 >> m2 >> k;

    cout << (h2-h)*60+(m2-m)-k << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define positiverep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int h,a;
  cin >> h >> a;
  cout << (h + a -1)/a;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}



Measured memory_bytes: 256
n = [0 for i in range(3)]

n = input().split()

coin = int(n[2])

total = 0

count = 0

day = 0

while(total < coin):
    total += int(n[0])
    count += 1
    if(count == 7):
        total += int(n[1])
        count = 0
    day += 1


print(day)



Measured memory_bytes: 5604
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 200020;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

using Point = complex<double>;
char A[2][100];
bool sign[101];
void solve() {
	int N; cin >> N;
	REP(i, 2)REP(j, N)cin >> A[i][j];
	int i = 0;
	int ans = 1;
	while (i < N) {
		if (i == 0) {
			ans = 3;
			if (A[0][0] == A[1][0]) {
				sign[i] = 0;
				i++;
			}
			else {
				ans = 6;
				sign[i] = sign[i + 1] = 1;
				i += 2;
			}
		}
		else {
			if (A[0][i] == A[1][i]) {
				sign[i] = 0;
				if (sign[i - 1] == 0)ans *= 2;
				else ans *= 1;
				ans %= MOD;
				i++;
			}
			else {
				sign[i] = sign[i + 1] = 1;
				if (sign[i - 1] == 0) {
					ans *= 2;
				}
				else {
					ans *= 3;
				}
				i += 2;
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// int q; cin >> q;
	// while (q--)
	solve();
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;

Int N, M, Q;
std::vector<std::vector<Int>> choice;

void dfs(std::vector<Int>& A, Int cnt) {
	if (cnt + 1 == N) {
		choice.push_back(A);
		return;
	}
	rep(i, M) {
		auto tmp = A;
		if (tmp.back() <= i + 1) {
			tmp.push_back(i + 1);
			dfs(tmp, cnt + 1);
		}
	}
}


void calc() {

	Int A, B, N; std::cin >> A >> B >> N;
	Int x = std::min(B - 1, N);
	std::cout << (Int)((double)(A * x) / (double)B) - A * (Int)((double)x / (double)B);

}


int main() {

	calc();

	return 0;
}

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

vector<vector<int> > edge;
bool visited[128];
int n;
int depth = 0;

int solve(int k) {
	if(visited[k])
		return -1;
	visited[k] = true;
	int res = 0;
	for(int i = 0; i < edge[k].size(); i++) {
		res = max(res, solve(edge[k][i]) + 1);
	}
	visited[k] = false;
	return res;
}

int main() {
	while(cin >> n, n) {
		for(int i = 0; i < 128; i++)
			visited[i] = false;
		edge.clear();
		edge.resize(100);
		for(int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b;
			a--; b--;
			edge[a].push_back(b);
			edge[b].push_back(a);
		}

		int res = 0;
		for(int i = 0; i < 100; i++) {
			res = max(res, solve(i) + 1);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1220
#include<stdio.h>
int main()
{
    long long i,n;
    scanf("%lld",&n);
    for(i=1;; i++)
    {
        if(i*i==0)
        {
            printf("%lld\n",i*i);
            break;
        }

        if(i*i>n)
        {
            printf("%lld\n",(i-1)*(i-1));
            break;
        }
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <vector>

constexpr int X = 1000000;

void solve() {
    std::vector<std::vector<int>> iss(X + 1);

    int n;
    std::cin >> n;

    for (int i = 0; i < n; ++i) {
        int x;
        std::cin >> x;
        iss[x].push_back(i);
    }

    std::vector<bool> ok(n, true);
    for (int x = 1; x <= X; ++x) {
        if (iss[x].empty()) continue;

        if ((int)iss[x].size() > 1) {
            for (auto i : iss[x]) ok[i] = false;
        }

        for (int y = x * 2; y <= X; y += x) {
            for (auto i : iss[y]) ok[i] = false;
        }
    }

    std::cout << std::accumulate(ok.begin(), ok.end(), 0) << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 32964
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<string>
#include<map>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/////////

struct S{
	int t;
	int c;
	int i;
	S(){};
	S(int t, int c, int i) : 
		t(t), c(c), i(i) {};
	bool operator<(S const &a) const{
		if(c != a.c) return c < a.c;
		if(t != a.t) return t < a.t;
		return i < a.i;
	};
};

set<S> q;

void solve(){
	int w, h;
	scanf("%d %d",&w,&h);
	fi(0, w){
		int pi;
		scanf("%d ",&pi);
		q.insert(S(0, pi, i));
	}
	fi(0, h){
		int qi;
		scanf("%d",&qi);
		q.insert(S(1, qi, i));
	}

	ll ans = 0;
	ll takeW = 0;
	ll takeH = 0;
	while(sz(q)){
		S cur = (*q.begin());
		q.erase(cur);

		if(cur.t == 0){
			ans += (h + 1 - takeH) * 1LL * cur.c;
			++takeW;
		}else{
			ans += (w + 1 - takeW) * 1LL * cur.c;
			++takeH;
		}
	}
	printf("%lld\n",ans);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int h[100005], dp[100005];
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i <= n; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
s=1

def tousa(l,r):
    return((l+r)*(r-l+1)//2)

for i in range(K,N+1):
    s+= (tousa(N-i+1, N) - tousa(0, i-1) + 1)
# print(s)
print(s%(10**9+7))

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,p=0,q=0;
  cin>>N;
  q=N;
for(int i=8;i>=0;i--){
    int x=1;
  for(int j=i;j>0;j--){x*=10;
  }
  	p+=q/x;
  	q-=(q/x)*x;
}
if(N%p==0){cout<<"Yes";}
  else{ cout <<"No";}


}

Measured memory_bytes: 256
N, D = map(int,input().split())
A = []
for i in range(N):
    XY = list(map(int,input().split()))
    A.append(XY)
B =[]
for i in A:
    x = i[0] ** 2 + i[1] ** 2
    B.append(x)
ans = 0

for i in B:
    if i <= D ** 2:
        ans += 1

print(ans)



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

ll maxi(ll a, ll b){
    return (a>b)? a : b;
}


int main(){
    ll n, k; cin>> n>> k;
    ll w[n+1]={0}, p[n+1]={0};
    for(ll i=1; i<=n; i++) cin>> w[i]>> p[i];
    ll a[2][k+1];
    for(ll i=0; i<=1; i++){
        for(ll j=0; j<=k; j++) a[i][j]=0;
    }
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=k; j++){
            a[1][j]=a[0][j];
            if(j>=w[i] && a[1][j]<a[0][j-w[i]]+p[i]) a[1][j]=a[0][j-w[i]]+p[i];
            //cout<< a[i][j]<< " ";
        }
        for(ll j=1; j<=k; j++){
            a[0][j]=a[1][j];
            //cout<< a[i][j]<< " ";
        }
        //cout<< endl;
    }
    cout<< a[1][k]<< endl;
}


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

const ll mod = 1e9 + 7;

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

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

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

    string s;
    cin >> s;
    rep(i, s.size()) cout << "x";
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n;
    cin >> n;
    vll v(n);
    cin >> v;
    sort(all(v));

    double ans = v[0];
    REP(i,n-1) ans = (ans + (double)v[i+1])/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();

        for(int i = 0; i < S.length(); i++) {
            int n = (int)S.charAt(i) + N;
            if(n > 90) n -= 26;
            char c = (char)(n);
            System.out.print(c);
        }
    }
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c; 
    if(a == b && a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    float A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if(ceilf(A/D) >= ceilf(C/B)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3724
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import decimal



if __name__ == "__main__":
    x = int(input())
    dp = [0]*101010
    dp[0] = 1
    for i in range(100,101010):
        for j in range(100,106):
            if dp[i-j]:
                dp[i] = 1
    print(dp[x])

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e3 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll a, b;
        cin >> a >> b;
        if (a <= 0 && b >= 0) cout << "Zero";
        else {
                if (a > 0) {
                        cout << "Positive";
                } else {
                        if ((b - a) % 2 == 0) cout << "Negative";
                        else cout << "Positive";
                }
        }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[3005][3005];
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
    string s,ss;
    cin>>s>>ss;
    for(int i=0;i<=s.size();i++)
    {
        for(int j=0;j<=ss.size();j++)
        {
            if(i==0||j==0)
                continue;
               else if(s[i-1]==ss[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string ans;
    int i=s.size(),j=ss.size();
    while(i&&j)
    {
           if(s[i-1]==ss[j-1])
           {
            ans+=s[i-1];
               i--;
               j--;
           }
           else if(dp[i-1][j]>dp[i][j-1])
            i--;
           else
            j--;

    }
    for(int i=ans.size()-1;i>=0;i--)
        cout<<ans[i];

    return 0;
}


Measured memory_bytes: 35456
# coding: utf-8

# https://atcoder.jp/contests/abc076/tasks/abc076_c
# 20:47-


def main():
    S = input()
    T = input()

    len_S = len(S)
    len_T = len(T)

    if len_T > len_S:
        return "UNRESTORABLE"
    
    condicates = []
    
    for i in range(len_S - len_T + 1):
        next_i = False
        part = S[i:i+len_T]
        
        for t, p in zip(T, part):
            if p != "?" and t != p:
                next_i = True
                break
        
        if next_i:
            continue
        
        # T == partの場合
        condicates.append((S[:i] + T + S[i+len_T:]).replace("?", "a"))
    
    return sorted(condicates)[0] if len(condicates) > 0 else "UNRESTORABLE"


print(main())


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, ans = -10000000000000, ans_idx=-1, ans_l=-1;
  std::cin >> N;
  std::vector<ll> A(N+1);
  for(int i=1;i<=N;i++) std::cin >> A[i];
  for(int i=1;i<=N;i++){
    ll tmp = 0;
    for(int j=0;i+j<=N;j+=2){
      if(A[i+j]>0||j==0) tmp += A[i+j];
      if(ans < tmp) ans = tmp, ans_idx = i, ans_l = j/2;
    }
  }
  ll c = 0;
  std::vector<ll> a;
  std::cout << ans << '\n';

  for(int i=(ans_idx+ans_l*2)-2;i>=ans_idx;i-=2) if(A[i]<0) c++, a.push_back(i);
  for(int i=1;i<ans_idx;i++) a.push_back(1);
  for(int i=0;i<ans_l-c;i++) a.push_back(2);
  for(int i=(N-ans_idx-ans_l*2)+1;i>=2;i--) a.push_back(i);


  std::cout << a.size() << '\n';
  for(int i=0;i<a.size();i++) std::cout << a[i] << '\n';
  return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define LOOP(i,o) for(i=0;i<o;i++)
int main() {
  int n;
  cin>>n;
  int i;
  vector<int> a(n);
  LOOP(i,n){
    cin>>a[i];
  }
  int ans=0;
  LOOP(i,n-1){
    for(int j=i+1;j<n;j++){
      ans+=a[i]*a[j];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
digit = len(str(n))

ans = 0
for i in range(1,digit+1):
    if i%2 == 1:
        if i == digit:
            if  i == 1:
                ans += n
            else:
                ans += n-int('9'*(i-1))
        else:
            ans += 9*10**(i-1)
print(ans)


Measured memory_bytes: 2940
N,MA,MB = map(int,input().split())
ABC = [tuple(map(int,input().split())) for i in range(N)]

INF = float('inf')
from collections import defaultdict
dp = defaultdict(lambda: INF)
dp[(0,0)] = 0
for a,b,c in ABC:
    dp2 = defaultdict(lambda: INF)
    for (pa,pb),pc in dp.items():
        dp2[(pa,pb)] = min(dp2[(pa,pb)], pc)
        dp2[(pa+a, pb+b)] = min(dp2[(pa+a, pb+b)], pc+c)
    dp = dp2

ans = INF
for i in range(1,401):
    ans = min(ans, dp[(MA*i, MB*i)])
print(-1 if ans==INF else ans)

Measured memory_bytes: 16208
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

long long int max_ll(long long int a, long long int b) {
	if (a > b) {
		return a;
	}
	else
	{
		return b;
	}
		
}

long long int donguri(long long int N, long long int go, long long int so, long long int bo, long long int gd, long long int sd, long long int bd) {
	vector<long long int> dp(N + 1, 0);
	//long long int dp[5005*5005+1];
	dp[0] = 0;
	for(long long int i = 0;i < N + 1; i++) {
		dp[i] = i;
		if (i >= go) {
			dp[i] = max_ll(dp[i], dp[i - go] + gd);
		}
		if (i >= so) {
			dp[i] = max_ll(dp[i], dp[i - so] + sd);
		}
		if (i >= bo) {
			dp[i] = max_ll(dp[i], dp[i - bo] + bd);
		}
	}
	return dp[N];
}

int main() {
	long long int N;
	long long int ga, sa, ba;
	long long int gb, sb, bb;

	cin >> N;
	cin >> ga >> sa >> ba;
	cin >> gb >> sb >> bb;

	long long int N2 = donguri(N, ga, sa, ba, gb, sb, bb);
	long long int N3 = donguri(N2, gb, sb, bb, ga, sa, ba);

	cout << N3 << endl;

	return 0;
}



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

set<int> s;

vector<int> v,e;
long long int g[10][10];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	v.emplace_back(1);
	v.emplace_back(2);
	int now=3;
	s.insert(1);
	s.insert(2);
	s.insert(3);
	for(int i=2;i<=8;i++){
		while(true){
			bool sw=0;
			for(int j=0;j<i;j++)
				if(s.find(v[j]+now)!=s.end())
					sw=true;
			if(s.find(now)!=s.end())	sw=true;
			if(!sw){
				for(int j=0;j<i;j++)
					s.insert(v[j]+now);
				v.emplace_back(now);
				now++;
				break;
			}
			now++;
		}
	}
	g[0][1]=g[1][0]=1;
	e.emplace_back(0);
	e.emplace_back(1);
	long long int ans=0;
	for(int i=2;i<10;i++){
		long long int M=0;
		do{
			long long int tmp=0;
			for(int j=0;j<i-1;j++)
				tmp+=g[e[j]][e[j+1]];
			M=max(M,tmp);
		}while(next_permutation(e.begin(),e.end()));
		M++;
		e.emplace_back(i);
		sort(e.begin(),e.end());
		for(int j=0;j<i;j++)
			g[j][i]=g[i][j]=M*v[j];
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cout<<g[i][j]<<' ';
		cout<<endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
    int a[10005];
    int main()
    {
        int n;scanf("%d",&n);
        for(int i=0;i<10;i++) a[111*i]=1;
        if(a[n/10]||a[n%1000]) printf("Yes\n");
        else printf("No\n");
        return 0;
    }

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char> > a(H, vector<char>(W, '.'));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      char temp;
      cin >> temp;
      a[i][j] = temp;
    }
  }  
  int i = 0, j = 0;
  while((i < H) && (j < W)){
    if (((i<(H-1)) && (a[i+1][j] == '#')) && ((j<(W-1)) && (a[i][j+1] == '#'))){
      cout << "Impossible" << endl;
      return 0;
    }else if ((i<(H-1)) && (a[i+1][j] == '#')){
      a[i][j] = '.';
      i++;
    }else if ((j<(W-1)) && (a[i][j+1] == '#')){
      a[i][j] = '.';
      j++;
    }else{
      break;
    }
  }
  a[i][j] = '.';
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (a[i][j] == '#'){
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  s1.at(0) = s1.at(0) + ('A' - 'a');
  s2.at(0) = s2.at(0) + ('A' - 'a');
  s3.at(0) = s3.at(0) + ('A' - 'a');
  cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ff first
#define ss second
#define ll long long
#define int long long
#define pii pair<ll,ll>
#define vi vector<ll>
#define mii map<ll,ll>
#define pb push_back
#define mp make_pair
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
#define all(v) v.begin(),v.end()
void kehsihba(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	kehsihba();
	ll n,m;
	cin>>n>>m;
	ll arr[m];
	ll sum=0;
	for(int i=0;i<m;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	if(sum>n){cout<<-1;}
	else{cout<<n-sum;}
	return 0;
}

Measured memory_bytes: 3736
n, m = gets.split.map(&:to_i)

edge = Array.new(n+1) {[]} 

m.times do
    x, y, z = gets.split.map(&:to_i)
    edge[x] << [y, z % 2]
    edge[y] << [x, z % 2]
end

c = Array.new(n+1)
ans = 0
1.upto(n) do |i|
    next if c[i]
    ans += 1
    c[i] = 1
    que = [i]

    while now = que.shift
        edge[now].each do |y, z|
            next if c[y]
            c[y] = z == 0 ? c[now] : 3 - c[now]
            que << y
        end
    end
end

p ans

Measured memory_bytes: 28028
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N;
    scanf("%d\n", &N);

    int *A = malloc(sizeof(int) * N);
    int *B = malloc(sizeof(int) * N);
    int *C = malloc(sizeof(int) * (N-1));

    for(int ni=0; ni<N; ni++){
        scanf("%d", A+ni);
    }
    for(int ni=0; ni<N; ni++){
        scanf("%d", B+ni);
    }
    for(int ni=0; ni<N-1; ni++){
        scanf("%d", C+ni);
    }

    int res = B[A[0]-1];
    for(int ni=1; ni<N; ni++){
        if(A[ni-1] == A[ni]-1){
            res += B[A[ni]-1] + C[A[ni-1]-1];
        } else {
            res += B[A[ni]-1];
        }
    }
    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int sieve(int n)
{
	vector<int> vec, primes;
	for (int i = 2; i <= 2 * n; ++i)
		vec.push_back(i);

	int th = pow(2 * n, 0.5);
	while(vec.front() <= th){
		int top = vec.front();
		primes.push_back(top);
		auto it = remove_if(vec.begin(), vec.end(),
			[&](int& e) -> bool{
			if (e % top)
				return false;
			return true;
		});
		vec.erase(it, vec.end());
	}

	for (int& e:vec)
		primes.push_back(e);

	auto it = remove_if(primes.begin(), primes.end(),
		[&](int& e)-> bool{
		if (e <= n)
			return true;
		return false;
	});
	primes.erase(it, primes.end());

	return primes.size();
}

int main()
{
	int in;
	while ( cin >> in )
	{
		if (!in)
			break;
		int ret = sieve(in);
		cout << ret << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int a = 0,b = {0},n;
    for(int i = 0;i < 4;i++){
        cin >> n;
        a += n;
    }
    for(int i = 0;i < 4;i++){
        cin >> n;
        b += n;
    }
    if(a < b)cout << b << endl;
    else cout << a << endl;
}

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

bool JudgeEnd(vector<int> &a) {
  for (int i=0; i<a.size(); i++) {
    if (a.at(i)%2 != 0) {return true;}
    a.at(i)/=2;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  int ans=0;
  while(JudgeEnd(a) == false) {
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
import sys

input = sys.stdin.readline

N = int(input().strip())
ps = list(map(int, input().strip().split(' ')))

sorted_list = sorted(ps)

if ps == sorted_list:
    print('YES')
    sys.exit(0)

for i in range(0, N - 1):
    for j in range(i + 1, N):
        mirror = ps[:]
        mirror[i], mirror[j] = mirror[j], mirror[i]
        if mirror == sorted_list:
            print('YES')
            sys.exit(0)
print('NO')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
int main(){
  int n; cin>>n;
  vector<int> length(2*n);
  int i,ans=0;
  rep(i,2*n){cin>>length[i];}
  sort(length.begin(),length.end());
  rep(i,2*n){if(i%2==0){ans+=length[i];}}
  cout<<ans<<endl;
  return 0;            
}
  
  


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
	//#pragma GCC target("avx,avx2,fma")
	//#pragma GCC optimization ("unroll-loops")
	
    #include<bits/stdc++.h>
    using namespace std;
	
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define ff first
    #define ss second
    #define null NULL
    #define MAX 1000000000  // 1x10^9
    #define all(c) (c).begin(),(c).end()
    #define eb emplace_back
    #define pb push_back
    #define pf push_front
    #define lb lower_bound   //used for sortted 
    #define ub upper_bound 
    #define m_p make_pair      
    #define mod 1000000007
    #define For(i,n) for(int i=(0);i<(n);++i)
    #define FOR(i,a,b) for(int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
    #define in(s3) inserter((s3), (s3).begin())  //	set_union(all(s1),all(s2),in(s3));
    typedef vector<ll> vl;
    typedef vector< vl > vvl;
    typedef pair< ll,ll> pll;
    typedef map< ll,ll> mll;
    
    //  A-65 Z-90 a-97 z-122   A-a = 32   Z-A = z-a = 35
    //	v.push_back(make_pair(min(2 * k[i], l[i]) - min(k[i], l[i]), i));      //int pos = v[i].second;
    //	floor(log10(no) + 1);                   //	to_string(no).length();             ----- length of a number
	//  llabs - long long of abs
	//  labs -long of abs
	//  sqrtf - sq root of float
	//  sqrtl - sq of long double    ( cout << fixed << setprecision(12) << sqrtl(val2) << endl; )
	//  it = find (all(vec), e);     if(it != vec.end());       it - vec.begin();
   	//	size_t found = str.find(str1);    if(found != string::npos); 	 cout<<found;
    	 
	/*	
		1. ^ is XOR and is used to to check odd occurance of number as a number XORed with itself results in zero so all even	occurrances result in zero.
		2.   & is used to check even or odd. (x & 1) ? printf("Odd") : printf("Even"); 
		3.   left shift(<<) - *         right shift(>>) - /
		4.   int a[] = { 1, 7, 2, 4, 8, 3 }; 
    		 int l = sizeof(a) / sizeof(a[0]); 
    		 sort(a, a + l);  reverse(a, a + l); accumulate(a, a + l, 0); *max_element(a, a + l);
	*/
	
	string to_string(char& x) {      
		string s(1,x);
		return s;    
	} 
	struct obj {
		ull val1;
		ull val2;
		ull pos;
	};
	bool cmp(const pair<int,int>&a,const pair<int,int>&b) {
		if(a.first==b.first)
		return a.second<b.second;
		return a.first<b.first;
	}

	int main() {
	/*	ull sum=0,n,no,sum1=0,total=0;
		vector<ull> v;
		cin>>n;
		while(n--)
		{
			cin>>no;
			v.pb(no);
		}
		
		for(ull i=0;i<v.size();i++)
		{
			sum+=((v[i])%mod);
			sum=sum%mod;
		}
		
		for(ull i=0;i<v.size();i++)
		{
			sum1+=((v[i])%mod);
			sum1=sum1%mod;
			total+=((v[i]%mod)*(sum-sum1))%mod;
			total=total%mod;
		}
		cout<<total%mod;
		return 0;*/
		ll n;
		cin>>n;
   ll a;
   ll sum=0,ans=0;
   for(ll i=0;i<n;i++){
    cin>>a;

    ans=(ans+((sum*a)%mod))%mod;
   
    sum=(sum+a)%mod;
   }
   cout<<ans<<endl;
   return 0;
	}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  cout<<n*n<<endl;
}

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

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	long long ans = 1;
	for(int i = 1; i <= n; i ++)
		ans *= i;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3140
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


N = int(input())
#a,b= map(int,input().split())
P = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)
c=0
mi=10**8
for i in range(N):
    if P[i] < mi:
        mi = P[i]
        if P[i]==1:
            c+=1
            print(c)
            exit()

        c+=1


Measured memory_bytes: 24744
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(R, G),
    X is R + 2 * (G - R),
    writeln(X).


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

int main(){
  int N;
  int sum=0;
  int temp;
  cin >> N;
  temp=N;
  for(int i=1;i<=8;i++){
    sum+=temp%10;
    temp/=10;
  }
  if(N%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;

int main(){
	int N, a;
	cin >> N;
	int mn = MOD, mx = -MOD, mni = 0, mxi = 0;
	for (int i = 0;i < N;i++) {
		cin >> a;
		if (mn > a) mn = a, mni = i;
		if (mx < a) mx = a, mxi = i;
	}
	if (mn >= 0) {
		cout << N - 1 << endl;
		for (int i = 1;i < N;i++)
			cout << i << " " << i + 1 << endl;
	}
	else if (mx <= 0) {
		cout << N - 1 << endl;
		for (int i = N;i > 1;i--)
			cout << i << " " << i - 1 << endl;
	}
	else if (-mn > mx) {
		cout << N * 2 - 2 << endl;
		for (int i = 0;i < N;i++) {
			if (i != mni) cout << mni + 1 << " " << i + 1 << endl;
		}
		for (int i = N;i > 1;i--) {
			cout << i << " " << i - 1 << endl;
		}
	}
	else {
		cout << N * 2 - 2 << endl;
		for (int i = 0;i < N;i++) {
			if (i != mxi) cout << mxi + 1 << " " << i + 1 << endl;
		}
		for (int i = 1;i < N;i++) {
			cout << i << " " << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		sc.close();
		
		System.out.println(a+b+c - (int)Math.max(Math.max(a, b), c));

	}

}


Measured memory_bytes: 22100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String a = in.nextString();
            String b = in.nextString();

            int c = new BigInteger(a).compareTo(new BigInteger(b));
            out.println(c > 0 ? "GREATER" : c < 0 ? "LESS" : "EQUAL");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 22868
import sys
a, b, c, d = [n for n in list(input())]
n = 3

for bit in range(1<<n):
    #print(bit)
    op = []
    for i in range(n):
        if bit & (1<<i):
            op.append('+')
        else:
            op.append('-')
    #print(op)

    formula = a + op[2] + b + op[1] + c + op[0] + d
   
    if eval(formula) == 7:
        print(formula+'=7')
        sys.exit(0)

Measured memory_bytes: 9060
import itertools
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 9100
import numpy as np
n, m, x = map(int, input().split())

A = np.array([list(map(int, input().split())) for i in range(n)])

# reigaishori
if A.sum(axis=0)[1:].min()<x:
    print(-1)
else:
    kouho=[]
    for i in range(1,2**n):
        tmp=np.array([0]*(m+1))
        for j in range(n):
            if (i>>j)&1:
                tmp=tmp+A[j,]
        if tmp[1:].min()>=x:
            kouho.append(tmp[0])
    print(min(kouho))
    

Measured memory_bytes: 27408
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N; cin >> N;
    VI A(N);

    VI a, b;
    REP(i, N)
    {
        cin >> A.at(i);
    }
    
    RSORT(A);
    REP(i, N)
    {
        if (i % 2 == 0) a.pb(A.at(i));
        else b.pb(A.at(i));
    }
    cout << accumulate(ALL(a), 0)- accumulate(ALL(b), 0) << endl;
    return 0;
}



Measured memory_bytes: 256
def sieve(n):
	is_prime = [1] * (n + 1)
	is_prime[0], is_prime[1] = 0, 0
	for i in range(2, n+1):
		if not is_prime[i]:
			continue
		j = i*2
		while j <= n:
			is_prime[j] = 0
			j += i
	return is_prime

def resolve():
	q = int(input())
	qs = [list(map(int, input().split())) for _ in range(q)]
	ps = sieve(10**5)
	seq = [0] * (10**5+1)
	for i in range(len(ps)-1, 1, -1):
		if ps[i] and ps[(i+1)//2]:
			continue
		ps[i] = 0
	for i in range(1, 10**5):
		seq[i+1] = seq[i] + ps[i+1]
	for l, r in qs:
		if l == r:
			print(ps[l])
		else:
			print(seq[r] - seq[l-1])
resolve()

Measured memory_bytes: 70360
def actual(n):
    s = str(n)

    if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:
        return 'Yes'
    return 'No'

    # if len(set(str(n))) <= 2:
    #     return 'Yes'
    #
    # return 'No'

s = input()
print(actual(s))

Measured memory_bytes: 2940
n, k, q = gets.split(" ").map(&:to_i)
ary = []
n.times do 
    ary << k-q
end
(1..q).each do |j|
    a = gets.to_i
    ary[a-1]+=1
end
ary.each do |m|
    if m >= 1
        puts "Yes"
    else
        puts "No"
    end
end

Measured memory_bytes: 4220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
		int ans=0;

		ans+=a>=b?b:a;
		ans+=c>=d?d:c;

		System.out.println(ans);

	}
}

Measured memory_bytes: 27036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> H(N);
    rep(n,0,N) cin>>H.at(n);

    int sum=accumulate(ToEnd(H),0),ans=0;
    while(sum>0){
        bool less=true;
        int _sum=0,_ans=0;
        rep(n,0,N){
            H.at(n)--;
            if(H.at(n)>=0){
                _sum++;
                if(less) _ans++;
                less=false;
            }else{
                less=true;
            }
        }

        sum-=_sum;
        ans+=_ans;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl: return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    from collections import defaultdict

    MOD = 10 ** 9 + 7
    A_MX = 10 ** 6

    N = int(input())
    *a, = map(int, input().split())

    s = Sieve(n=A_MX)

    dict_lcm = defaultdict(int)
    for x in a:
        for prime, cnt in s.factor(x):
            dict_lcm[prime] = max(dict_lcm[prime], cnt)

    lcm = 1
    for prime, count in dict_lcm.items():
        lcm = lcm * pow(prime, count, MOD) % MOD

    ans = 0
    for x in a:
        ans = (ans + lcm * pow(x, MOD - 2, MOD)) % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15460
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
p1 = 0
q1 = 0
count = 1
for i in itertools.permutations(range(1, n+1)):
    if p == i:
        p1 = count
    if q == i:
        q1 = count
    count += 1
print(abs(p1-q1))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#pragma once
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) or s.at(1) == s.at(2) or s.at(2) == s.at(3)) puts("Bad");
    else puts("Good");
}

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

using namespace std;

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

#define MAX_N 100000
int arr[MAX_N];
int dp[MAX_N];
int N;

int main() {
	cin >> N;
	FOR(i,0,N) {
		cin >> arr[i];
		dp[i] = INT_MAX;
	} 
	dp[1] = abs(arr[1]-arr[0]);
	if (N == 2) {
		cout << dp[1] << "\n";
		return 0;
	}
	FOR(i, 2, N) {
		if (dp[i-2] == INT_MAX) dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),abs(arr[i]-arr[i-2]));
		else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),
			dp[i-2]+abs(arr[i]-arr[i-2]));
	}

	cout << dp[N-1] << "\n";
   
    return 0;
}

Measured memory_bytes: 1024