akhauriyash/Code-Regression huggingface dataset:
a, b, c = map(int,input().split())
r = a
d = b
x_init = c
result = []

def main(_r, _d, _x, _i):
    result.append(int(_r) * int(_x) - int(_d))
    return result[_i]

for i in range(10):
    if i == 0:
        main(r, d, x_init, i)
    else:
        main(r, d, result[i - 1], i)
    print(result[i])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

struct pairs{
  int price;
  int num;
};
int main(int argc, char *argv[]) {
  /*
  cin>>x;
  cout<<x<<endl;
  */
  int i,j,n,m,a,b=0,c;
  double ans=0,tmp;
  cin>>n>>m;
  vector<struct pairs> A(n);
  for(i=0;i<n;i++){
    cin>>A[i].price>>A[i].num;
  }
  sort(A.begin(),A.end(),[](const pairs& x, const pairs& y) { return x.price < y.price;});
  for(i=0;i<n;i++){
    if(A[i].num<=m){
      tmp=double(A[i].price)*A[i].num;
      ans=ans+tmp;
      m-=A[i].num;
    }else{
      tmp=double(A[i].price)*m;
      ans=ans+tmp;
      m=0;
    }
    if(m==0)
      break;
  }
  printf("%.0lf\n",ans);
}


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

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n)
	{
			bool flag= false;
		for(int i=1;i<10;i++)
		{
			for(int j=1;j<10;j++)
			{
				if(n==i*j)
					flag=true;
			}
		}
		if(flag)
			cout<<"Yes"<<endl;
		if(!flag)
			cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    sort(ALL(L));
    ll ans = 0;
    for(ll i = N - 1; i >= N - K; --i){
        ans += L[i];
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N, M;
  cin >> N >> M;
  int A[M];
  rep(i, M) cin >> A[i];

  rep(i, M) { N -= A[i]; }
  if (N >= 0)
    cout << N << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3632
def LI(): return list(map(int, input().split()))
n = int(input())
a = LI()
cnt = 0
tmp_cnt = 1
start = a[0]
for i in range(1, n):
    if a[i] != start:
        start = a[i]
        cnt += tmp_cnt//2
        tmp_cnt = 1
    else:
        tmp_cnt += 1
cnt += tmp_cnt // 2
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
//事後メモ　あまり時間とれなかった。対応方針はOK。例2～で１つずつ多くなった。バグあり？
//引数の参照が多いのでなんとかしたいところ
void add_cand(vector<int> &p, int n, int g_score, int g, int &min_n, int target_i){
	for (int k = 0; k < p[target_i]; k++){
		n++;
		g_score += 100 * (target_i+1);
		if (g_score >= g){
			if (n < min_n){
				min_n = n;
				//cout << target_i << " "<< k << endl;
			}
			return;
		}
	}
}


void choise(int i, int d, vector<int> &p, vector<int> &t, int n, int g_score, int g, int &min_n, vector<int> cands){
	if (i == d){
		if (g_score >= g){
			if (n < min_n) min_n = n;
		}else{
			//次を足して、どこで達成するか判断。
			for (int j = 0; j < cands.size(); j++){
				int target_i = cands[j];
				add_cand(p, n, g_score, g, min_n, target_i);
			}
		}
		return;
	}
	choise(i+1, d, p, t, n + p[i], g_score + t[i], g, min_n, cands);  //足す場合
	cands.push_back(i);
	choise(i+1, d, p, t, n, g_score, g, min_n, cands);  //足さない場合
}

int main(){
	//input
	int d, g;
	cin >> d >> g;
	vector <int> p, c, t;
	p.resize(d);
	c.resize(d);
	t.resize(d);
	for (int i = 0; i < d; i++){
		cin >> p[i] >> c[i];
		t[i] = p[i]*100*(i+1) + c[i];
	}
	//judge
	int min_n = g, n = 0, g_score = 0;
	vector<int> cands;
	choise(0, d, p, t, n, g_score, g, min_n, cands);
	cout << min_n << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long int f1(long x[], long y[], long z[], int n, int m, int xn, int yn, int zn) ;
int main() {
  int n ,m, i, j, k;
  long int xs, ys, zs;
  long int max = 0, temp;
  long int x[1000], y[1000], z[1000];
  scanf("%d %d", &n, &m);
  for (i=0; i<n; i++) {
      scanf("%ld %ld %ld", &x[i], &y[i], &z[i]);
  }

  for (i=-1; i<=1; i+=2) {
      for (j=-1; j<=1; j+=2){
         for(k=-1; k<=1; k+=2) {
            temp = f1(x, y, z, n, m, i, j, k);
            //printf("%ld\n", temp);
            if (temp > max) {
                max = temp;
            }
         }   
      }
  }

  printf("%ld\n", max);
  return 0;
}

long int f1(long x[], long y[], long z[], int n, int m, int xn, int yn, int zn) {
    int i, j;
    long int array[1000];
    int max;
    long int result = 0;
    for (i=0; i<n; i++) {
        array[i] = x[i] * xn + y[i] * yn + z[i] * zn;
    }
    for (i=0; i<m; i++) {
        max = i;
        for (j=i+1; j<n; j++) {
            if(array[j] > array[max]) {
                max = j;
            }
        }
        result += array[max];
        //printf("%ld\n", result);
        array[max] = array[i];
    }

    return result;
}



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

int main()
{
string s;ll i,n,w=0,r=0;
cin>>n;
cin>>s;
for(i=0;i<n;i++)
{
    if(s[i]=='W')
        w++;
    else
        r++;
}
ll k=0;
for(i=1;i<=r;i++)
{
    if(s[i-1]=='R')
        k++;
}
cout<<min((r-k),w);
}


Measured memory_bytes: 3720
#include<iostream>
#include<set>

using namespace std;

int main()
{
    long long int x,k,a,b,n,ans=1,start=100;
    cin>>x;
    for(long long int i=1;;i++)
    {
        start+=(long long int)(start*0.01);
        ans=i;
        if(start>=x)
            break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
set<int> s;
int main(){
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        s.insert(a);
    }
    if(s.size()==n) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a;
ll x[55];

ll solve() {
    ll dp[n+2][2600];
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++) {
        for (int j = n; j > 0; j--) {
            for (int k = 0; k <= 2500; k++) {
                dp[j+1][k+x[i]] += dp[j][k];
            }
        }
        dp[1][x[i]]++;
    }

    ll res = 0;
    for (ll i = 1; i <= n; i++)
        res += dp[i][i*a];

    return res;
}

void input() {
    cin >> n >> a;
    for (int i = 0; i < n; i++)
        cin >> x[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}

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

int main(void){
  int a, b, c;

  cin >> a >> b >> c;

  if(a+b == c || a+c==b || b+c==a)
    cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#define VFOR(x,begin,num) for(int x=(begin);x<((begin)+(num));x++)
int main(){
  vector<ll> A;int N;
  cin >> N;
  VFOR(i,0,N) {int tmp;cin >> tmp;A.push_back(tmp);}
  sort(A.begin(),A.end());
  VFOR(i,0,N-1){
    if(A[i]==A[i+1]){cout << "NO";return 0;}
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 2420
N = int(input())
W = list(input() for i in range(N))
no = 0
if len(W) != len(set(W)):
    print('No')
else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            no += 1
    if no == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
# include <bits/stdc++.h>
using namespace std;
# define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
# define FDR(i, a, b) for (int i = (a); i >= (b); --i)
# define mem(a, x) memset(a, x, sizeof(a));
# define mp make_pair
# define pb push_back
typedef vector<int> Vi;
typedef tuple<int, int, int> Ti;
typedef pair<int, int> Pi;
typedef long long i64;
const int N = 100005;
const int MOD = 1000000007;
const int INF = 1000000000;

int a[N];

int main ()
{
    int n, k;
    scanf("%d %d", &n, &k);
    FOR(i, 1, n) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    int p = n + 1;
    FOR(i, 1, n) if (a[i] >= 0) {p = i; break;}
    if (p == 1) {
        printf("%d\n", a[k]);
    }
    else if (p == n + 1) {
        printf("%d\n", -a[n - k + 1]);
    }
    else {
        int ans = INF;
        if (p > k) ans = min(ans, -a[p-k]);
        if (n - p + 1 >= k) ans = min(ans, a[p+k-1]);
        FOR(i, p, n) {
            if (i - p + 1 < k && p > k - (i - p + 1)) ans = min(ans, a[i] - a[p-(k-(i-p+1))] + min(a[i], -a[p-(k-(i-p+1))]));
        }
        printf("%d\n", ans);
    }
    return 0;
}



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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)

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



int main(){
  ll N, K, Q;
  cin >> N >> K >> Q;
  
  vector<ll> point(N, K);
  vector<ll> pointget(N,0);
  
  ll a;
  
  rep(i,Q){
    cin >> a;
    pointget[a-1]++;
  }

  rep(i,N){
    point[i] += pointget[i] - Q;
    if(point[i] > 0) cout << "Yes" <<endl;
    else cout << "No" << endl;
  }

}
  


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int N=300010;
vector<int>e[N]; int n,dp[N];
void dfs(int x,int fa){ for (int i=0;i<e[x].size();i++) if (e[x][i]!=fa){ dfs(e[x][i],x); dp[x]^=dp[e[x][i]]+1; } }
int main(){
	scanf("%d",&n); for (int i=1;i<n;i++){ int x,y; scanf("%d%d",&x,&y); e[x].push_back(y);e[y].push_back(x); }
	dfs(1,-1); printf("%s\n",dp[1]?"Alice":"Bob"); return 0;
}

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

int main(){
  int N;
  double ans = 0.0, A;
  cin >> N;
  for(int i = 1; i <=N; ++i){
    cin >> A;
    ans += 1.0/A;
  }
  ans = 1.0 / ans;
  cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long long min=10000;
  long long l,r;
  scanf("%lld %lld",&l,&r);


  for(long long i=l;i<r;i++){
    for(long long j=l+1;j<=r;j++){

      if((i*j)%2019==0){
        puts("0");
        return 0;
      }
      if((i*j)%2019<min){
        min=(i*j)%2019;
      }
    }
  }

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


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N); cin >> A >> B >> C;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  LL cnt = 0;
  for (int b : B) {
    LL cnt_a = std::lower_bound(A.begin(), A.end(), b) - A.begin();
    LL cnt_c = C.end() - std::upper_bound(C.begin(), C.end(), b);
    cnt += cnt_a * cnt_c;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>

using namespace std;
long long ggd(long long number1,long long number2){
    long long m=number1;
    long long n=number2;
    long long r;
    
    if(number2 > number1){
        m = number2;
        n = number1;
    }
    r=m%n;
    while(r!=0){
        m=n;
        n=r;
        r=m%n;
    }
    
    return n;
}

long long lcm(long long number1,long long number2){
    return number1*number2/ggd(number1,number2);
}

int main() {
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    a=a-1;
    long long m1,m2,m3,m4,m5,m6,ans;
    m1=a/c;
    m2=a/d;
    m3=a/lcm(c,d);
    m4=b/c;
    m5=b/d;
    m6=b/lcm(c,d);
    ans=(b-(m4+m5-m6))-(a-(m1+m2-m3));
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 1e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
c=[list(map(int,input().split()))for _ in[0]*3]
b1,b2,b3=c[0]
a2,a3=c[1][0]-b1,c[2][0]-b1
if [c[1][1:],c[2][1:]]==[[a2+b2,a2+b3],[a3+b2,a3+b3]]:
    print('Yes')
else:
    print('No')

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9
int N;
int gcd(int a, int b){
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}
int main(){
  string s;
  int gsum = 0, psum = 0;
  cin >> s;

  REP(i, s.length()){
    if(s[i] == 'g')
      gsum++;
    else
      psum++;
  }
  cout << (gsum - psum) / 2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28

inline void chmax(int &a, int b) { a = max(a,b); }
inline void chmin(int &a, int b) { a = min(a,b); }

int main()
{
  int N, K;
  while(cin >> N >> K, N || K) {
    int large[100007] = {0};
    bool flag = false;
    int A;
    Rep(i,K) {
      cin >> A;
      if(A)large[A]++;
      else flag = true;
    }
    Rep(i,N + 1) {
      if(large[i + 1] > 0)large[i + 1] = large[i] + 1;
    }
    int val = large[N - 1];
    for(int i = N + 1; i >= 1; i--) {
      if(large[i] > 0) {
	large[i] = val;
      } else {
	val = large[i - 1];
      }
    }
    int maxv = 0;
    for(int i = 1; i <= N + 1; i++) {
      if(large[i]) {
	chmax(maxv,large[i]);
      } else if(flag) {
	chmax(maxv,1 + large[i - 1] + large[i + 1]);
      }
    }
    cout << maxv << endl;
  }
  return 0;
}

Measured memory_bytes: 3464
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int sum(int _num) {
	int sum = 0;
	while (1) {
		sum += _num % 10;
		_num /= 10;
		if (_num == 0) break;
	}
	return sum;
}

int main() {
	int N;
	int A, B;
	cin >> N >> A >> B;

	ll ans = 0;
	REPS(i, 1, N + 1){
		int buf = sum(i);
		if (buf >= A && buf <= B) {
			ans += i;
		}
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int cost[maxn];
int dp[maxn];
int main()
{
	int n;
	cin >> n;
	int k;
	cin >> k;
	for (int i=0 ; i<n ; i++) cin >> cost[i];
	//memset(dp,INT_MAX,sizeof(dp+1));
	for (int i=1 ; i<=n ; i++)
	dp[i] = INT_MAX;
	dp[0] = 0;
	for (int i=0 ; i<n ; i++)
	{
		for (int j=i+1 ; j<= i+k ; j++)
		{
			if(j<n)
			{
				dp[j] = min(dp[j] , dp[i] + abs(cost[j] - cost[i]));
			}
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 4408
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map(String::toInt)
    val sum =
        (1..n).filter { digitSum(it) in a..b }.sum()
    println(sum)
}

fun digitSum(n: Int): Int = n.toString().split("").filter(String::isNotEmpty).map(String::toInt).sum()


Measured memory_bytes: 42304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 1) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 1000000007;

int n, a, b;
int fact[200001];
int finv[200001];

int comb(int n, int k) {
	int ret = 1;
	for (int i = n; i >= n - k + 1; i--) {
		ret *= i;
		ret %= mod;
	}
	ret *= finv[k];
	ret %= mod;
	return ret;
}

signed main() {
	int i;
	
	cin >> n >> a >> b;
	
	fact[0] = 1;
	finv[0] = 1;
	for (i = 1; i <= 200000; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		finv[i] = powmod(fact[i], mod - 2, mod);
	}
	
	int res1 = powmod(2, n, mod);
	int res2 = comb(n, a) + comb(n, b) + 1;
	res2 %= mod;
	
	res1 = (res1 - res2 + mod) % mod;
	cout << res1 << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> a(m);
    rep(i, m)cin >> a[i].first >> a[i].second;
    sort(all(a));
    ll ans = 1, mi = inf;
    rep(i, m){
        mi = min(mi, a[i].second);
        if(mi <= a[i].first){
            mi = a[i].second;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
n,m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
hasi = Array.new(n,0)
m.times do
  a,b = gets.split.map(&:to_i)
  if h[a-1] > h[b-1]
    hasi[b-1] += 1
  elsif h[a-1] == h[b-1]
    hasi[a-1] += 1
    hasi[b-1] += 1
  else
    hasi[a-1] += 1
  end
end
sum = 0
hasi.each do |a|
  if a == 0
    sum += 1
  end
end
puts sum

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

if N%2 == 0:
    M = N+1
else:
    M = N+2


ans = 0
for x in range(1, M, 2):
    cnt = 0
    for i in range(1, x+1):
        if x%i == 0:
            cnt += 1
    if cnt == 8:
        ans += 1

print(ans)


Measured memory_bytes: 2940
//IIT Kanpur FacelessMen India
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif
int mk[805][805];
priority_queue<pair<int,pii> > Q;
char arr[805][805];
pii d[] = {mp(1,0),mp(-1,0),mp(0,1),mp(0,-1)};
pii operator +(pii a,pii b){
  return mp(a.X+b.X,a.Y+b.Y);
}
int main(){
  // freopen("product.in","r",stdin);
  // freopen("product.out","w",stdout);
  int h,w,k; scanf("%d%d%d",&h,&w,&k);
  pii st;
  REP(i,h) scanf("%s",arr[i]);
  REP(i,h) REP(j,w) if(arr[i][j]=='S') st=mp(i,j);
  REP(i,h) REP(j,w) mk[i][j]=mod;
  Q.push(mp(0,st));
  mk[st.X][st.Y]=0;
  int ans=mod;
  while(!Q.empty()){
    pii pt = Q.top().Y; int dis=-Q.top().X; Q.pop();
    int fl=0;
    REP(i,4){
      pii nx = pt+d[i];
      int nd = dis+1;
      if(arr[nx.X][nx.Y]=='#'){
        if(nd<=k) {
          nd=k+1;
        }
      }
      if(nx.X*nx.Y==0||nx.X==h-1||nx.Y==w-1){
        ans=min(ans,nd);
      }else if(nd<mk[nx.X][nx.Y]){
        mk[nx.X][nx.Y]=nd;
        Q.push(mp(-nd,nx));
      }
    }
  }
  if(ans!=mod) ans=(ans+k-1)/k;
  //ans=min(ans,1+(min(min(st.X,st.Y),min(h-1-st.X,w-1-st.Y))+k-1)/k);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 6644
hills = [0,0,0] # top3 highest > higher > high 

10.times{ 
	x = gets.to_i


	if x > hills[2] 
		hills[0] = hills[1]
		hills[1] = hills[2]
		hills[2] = x

	elsif x > hills[1]
		hills[0] = hills[1]
		hills[1] = x

	elsif x > hills[0] 
		hills[0] = x
	end


}
3.times do |i|
	puts hills[2-i]
end

Measured memory_bytes: 6092
#include <iostream>

using namespace std;

long solution(long H) {
  if (H == 1)
    return 1;
  if (H == 0)
    return 0;

  return 1 + 2 * solution(H / 2);
}

int main(int argc, char** argv) {
  long H;
  cin >> H;
  cout << solution(H) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

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

using namespace std;

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  int ta, tb;
  rep(i, a)
  {
    ta = i * 500;
    rep(j, b)
    {
      tb = j * 100;
      rep(k, c)
      {
        if((ta + tb + (k * 50)) == x) ++ans;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
const ll N=1e5+5;
ll bexpo(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==0)return bexpo(x*x,n/2);
    else return x*bexpo(x*x,(n-1)/2);
}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);} 
int Arr[N];
void initialize()
{
    for(int i = 0;i<N;i++)
    Arr[ i ] = i ;
}
int root(int i)
{
    while(Arr[ i ] != i)       
    {
     i = Arr[ i ];
    }
    return i;
}

void unio(int A ,int B)
{
    int root_A = root(A);       
    int root_B = root(B);  
    if(root_A<root_B)
        Arr[ root_A ] = root_B ;    
    else
        Arr[root_B]=root_A;
}
bool find(int A,int B)
{
    if( root(A)==root(B) )    
    return true;
    else
    return false;
} 
int main() {
FIO;
  ll n;
  cin>>n;
  ll a[n+1];
  ll i;
  for(i=1;i<=n;i++)
      cin>>a[i];
  ll dp[n+1];
   dp[1]=0;
  dp[2]=abs(a[2]-a[1]);
  for(i=3;i<=n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout<<dp[n];

}

Measured memory_bytes: 5132
#include <iostream>

using namespace std;
typedef long long int lint;

void answer()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c) cout << "Yes";
	else cout << "No";
	cout << endl;
}

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

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

using namespace std;

int main() {

	int INF = 50001;

	int n, m;
	scanf("%d %d", &n, &m);

	int T[n + 1];
	int C[m];
	for (int i = 0; i < m; ++i) {
		int coin;
		scanf("%d", &coin);
		C[i] = coin;
	}
//15 6
//1 2 7 8 12 50

	for (int j = 1; j <= n; ++j)
		T[j] = INF;
	T[0] = 0;

	for (int i = 0; i < m; ++i) {
		for (int j = C[i]; j <= n; ++j) {
			T[j] = min(T[j], T[j - C[i]] + 1);
		}
	}

	cout << T[n] << endl;
	return 0;
}

Measured memory_bytes: 3408
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp(int x,int y)
{
	return x > y;

}
int main()
{
	int a[11], i = 0;
	for (i = 0; i < 10; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 10,cmp);
	for ( i = 0; i < 3; i++)
	{
		printf("%d\n", a[i]);
	}
	
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e3 + 2;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 2e9;
    for (int p = 1; p <= 100; p++)
    {
        int val = 0;
        for (int i = 0; i < n; i++)
            val += abs(a[i] - p) * abs(a[i] - p);
        ans = min(ans, val);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>


using namespace std;

struct node
{
	node *next;
	node *prev;
	int num;
};


node *head;


void initialize()
{
	head = (node *)malloc( sizeof(node) );
		head->next = head;
		head->prev = head;

}


void insert(int m)
{
	node *p = (node *)malloc( sizeof(node) );

	p->num = m;
	p->next = head->next;
	head->next->prev = p;
	p->prev = head;
	head->next = p;
}

void del(node *p)
{
	p->prev->next = p->next;
	p->next->prev = p->prev;

	free(p);

}

void deletefirst()
{
	del(head->next);
	/*head->next->next->prev = head;
	free(head->next);
	head->next = head->next->next;*/
}

void deletelast()
{
	del(head->prev);
	/*head->prev->prev->next= head;
	free(head->prev);
	head->prev = head->prev->prev;*/
}

node* search(int key,int count)
{
	node* cur = (node *)malloc( sizeof(node) );
	cur = head->next;

	for(int i = 0; i < count; i++)
	{
		if (cur->num == key)
		{
			return cur;
		}
		cur = cur->next;
	}

    return NULL;
}

int main()
{
	node *pp = (node *)malloc( sizeof(node) );
	int n;
	int key;
	char str[12];

	int count = 0;

	initialize();

	scanf("%d", &n);

	for(int i = 0; i < n; i++)
	{
		scanf("%s", str);

		if (str[6] == 'F')
		{
			deletefirst();
			count--;

		}else if (str[6] == 'L')
		{
			deletelast();
			count--;

		}else
		{
			scanf("%d", &key);

			if (str[0] == 'i')
			{
				insert(key);
				count++;

			}else if (str[0] == 'd')
			{
				pp = search(key, count);
				if (pp != NULL)
				{
					del(pp);
					count--;
				}
				
			}
		}

	}

	pp = head->next;

	for(int i = 1; i <= count; i++)
	{
		if (i == count)
		{
			printf("%d\n", pp->num);
		}
		else
		{
			printf("%d ", pp->num);
		}
		pp = pp->next;
	}




	return 0;
}

Measured memory_bytes: 34404
n, m = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
b = [int(input()) for i in range(m)]

for i in range(n):
    sum = 0
    for j in range(m):
        sum += a[i][j] * b[j]
    print(sum)



Measured memory_bytes: 5976
import fractions


def solve(a,b,c,d):
    a -= 1
    bc = b // c
    bd = b // d
    bcd = b // (c*d//fractions.gcd(c, d))

    ac = a // c
    ad = a // d
    acd = a //  (c*d//fractions.gcd(c, d))

    return b - bc - bd + bcd - (a - ac - ad + acd)
    
if __name__ == "__main__":

    assert solve(4,9,2,3) == 2
    assert solve(10, 40, 6,8) == 23
    assert solve(314159265358979323, 846264338327950288, 419716939, 937510582) == 532105071133627368

    a, b, c, d = map(int, input().split())
    print(solve(a,b,c,d))



Measured memory_bytes: 64080
from collections import deque
S = deque(input())
Q = int(input())
Query = [[] for _ in range(Q)]
for i in range(Q):
    Query[i] = list(map(str,input().split()))

fl = 0
for q in Query:
    if q[0]=='1':
        fl += 1
    else:#q[0]=='2'
        # 前に追加
        if (q[1]=='1'):
            # 反転あり
            if fl&1:
                S.append(q[2])
            # 反転なし
            else:
                S.appendleft(q[2])
        # 後に追加
        else:#q[1]=='2'
            # 反転あり
            if fl&1:
                S.appendleft(q[2])
            # 反転なし
            else:
                S.append(q[2])

T = ''.join(S)
if fl&1:
    T = T[::-1]
print(T)

Measured memory_bytes: 44568
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N, K;
    cin >> N >> K;
    long k, counter=0;

    for(size_t i=0;i<N; i++)
    {
        cin >> k;
        if(k >= K) counter++;
    }
    cout << counter << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 200003, M = 2003, mod = 1000000007, inv2 = (mod + 1) >> 1;
int n, a[N], b[N], maxa, maxb, dp[M << 1][M << 1], fac[N], inv[N], ans;
bool vis[M << 1][M << 1];
inline int DP(int x, int y){
	if(x < -maxa || y < -maxb) return 0;
	if(vis[x + M][y + M]) return dp[x + M][y + M];
	vis[x + M][y + M] = true;
	return dp[x + M][y + M] = (dp[x + M][y + M] + DP(x, y - 1) + DP(x - 1, y)) % mod;
}
inline void init(int m){
	fac[0] = 1;
	for(Rint i = 1;i <= m;i ++) fac[i] = (LL) i * fac[i - 1] % mod;
	inv[1] = 1;
	for(Rint i = 2;i <= m;i ++) inv[i] = (LL) (mod - mod / i) * inv[mod % i] % mod;
	inv[0] = 1;
	for(Rint i = 1;i <= m;i ++) inv[i] = (LL) inv[i] * inv[i - 1] % mod;
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++){
		scanf("%d%d", a + i, b + i);
		maxa = max(maxa, a[i]);
		maxb = max(maxb, b[i]);
		++ dp[-a[i] + M][-b[i] + M];
	}
	init(maxa + maxb << 1);
	for(Rint i = 1;i <= n;i ++) ans = (ans + DP(a[i], b[i])) % mod;
	for(Rint i = 1;i <= n;i ++)
		ans = (ans - (LL) fac[a[i] + b[i] << 1] * inv[a[i] << 1] % mod * inv[b[i] << 1] % mod + mod) % mod;
	printf("%d", (LL) ans * inv2 % mod);
}

Measured memory_bytes: 83876
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define len(x) (int)(x).size()

typedef long long ll;
typedef long double ld;

using namespace std;

signed main(){
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;cin >> n;
    int x;cin >> x;
    ll sum = x, sum1 = 0 , negsum = 0;
    ll pref = -1;
    bool done = 0;
    int kek;
    vector<pair<ll,ll>>neg;
    for(int i = 1; i <n ; ++i){
        char ch;cin >> ch >> x;
        if(ch == '-'){
            neg.pb({sum , x});
            negsum += x;
        }
        sum += x;
    }
    /// first ways
    ll answer = -1e18;
    answer = max(answer , sum - 2 * negsum);
    ll cur = 0;
    for(int i = 0 ; i < len(neg) - 1; ++i){
        ll now = cur + neg[i + 1].fi - neg[i].fi;
        answer = max(answer , sum - 2 * now);
        cur += neg[i].se;
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 5240
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int K=sc.nextInt();
    int A=sc.nextInt();
    int B=sc.nextInt();
    if(A%K==0){System.out.println("OK");}
    else if(B%K==0){System.out.println("OK");}
    else{
      int a=A/K;
      int b =B/K;
      if(a==b){System.out.println("NG");}
      else{System.out.println("OK");}
    }
  }
}

Measured memory_bytes: 35724
def main():
    num, max_weigh = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    data.sort(key=lambda x: (x[0], -x[1]))
    split_data = []

    pre_data = data[0][0]
    pre_ind = 0
    for i in range(num):
        if pre_data != data[i][0]:
            split_data.append(data[pre_ind:i])
            pre_data = data[i][0]
            pre_ind = i
    split_data.append(data[pre_ind:num])

    while len(split_data) != 4:
        split_data.append([])

    ans = 0

    for i in range(-1, len(split_data[0])):
        if i == -1:
            sum_i = 0
            sum_i_w = 0
        else:
            sum_i += split_data[0][i][1]
            sum_i_w += split_data[0][i][0]
        if sum_i_w > max_weigh:
            break
        ans = max(ans, sum_i)

        for j in range(-1, len(split_data[1])):
            if j == -1:
                sum_j = 0
                sum_j_w = 0
            else:
                sum_j += split_data[1][j][1]
                sum_j_w += split_data[1][j][0]
            if sum_i_w + sum_j_w > max_weigh:
                break
            ans = max(ans, sum_i + sum_j)

            for k in range(-1, len(split_data[2])):
                if k == -1:
                    sum_k = 0
                    sum_k_w = 0
                else:
                    sum_k += split_data[2][k][1]
                    sum_k_w += split_data[2][k][0]
                if sum_i_w + sum_j_w + sum_k_w > max_weigh:
                    break
                ans = max(ans, sum_i + sum_j + sum_k)

                for l in range(-1, len(split_data[3])):
                    if l == -1:
                        sum_l = 0
                        sum_l_w = 0
                    else:
                        sum_l += split_data[3][l][1]
                        sum_l_w += split_data[3][l][0]
                    if sum_i_w + sum_j_w + sum_k_w + sum_l_w > max_weigh:
                        break
                    ans = max(ans, sum_i + sum_j + sum_k + sum_l)

    print(ans)



if __name__ == '__main__':
    main()


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    int i = 0;
    while (B <= A) {
        B*=2;
        ++i;
    }
    if (i > K) {
        cout << "No" << endl;
        return 0;
    }
    while (C <= B) {
        C *= 2;
        ++i;
    }
    if (i > K) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

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

int main(){
  int n; 
  cin >> n;
  int a[n];
  long long x=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    x+=a[i];
  }
  
  
  long long rex=0;
  long long ans=1000000000000000000;
  for(int i=0;i<n-1;i++){
    rex+=a[i];
    long long ansd=abs(x-2*rex);
    ans=min(ans,ansd);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3,unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
string s, t, u;
int a, b;
int main()
{
	spIO;
	cin >> s;
	for (int i = 0; i < s.size(); i++) cout << 'x';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 999721/* your task*/
#define NIL '\0'
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return key%(M-1); }

int find(char str[]){


  int i;
  i=0;
  long long j;
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(str,H[j])==0) return j;
    i++;
    if(H[j][0]==NIL || i==M) return NIL;
  }
 

}

int insert(char str[]){



  int i;
  long long j;
  i=0;
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(H[j][0]==NIL){
      strcpy(H[j],str);
      return j;
    }
    else i++;
    if(i==M) break;
  }

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

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

int top = 0, s[1000];

void push(int); 
int pop(void);


int main(void) {
    int a, b;
    char s[128];

    while(scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if(s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());

    return 0;
}

void push(int x) {
    s[++top] = x;
}

int pop(void) {
    top--;
    return s[top+1];
}



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"EQUAL"<<endl;
    }
    else if(a.size() > b.size())
    {
        cout<<"GREATER"<<endl;
    }
    else if(a.size() < b.size())
    {
        cout<<"LESS"<<endl;
    }
    else
    {
        for(int i = 0; i < a.size(); i++)
        {
            if(a[i]>b[i])
            {
                cout<<"GREATER"<<endl;
                break;
            }
            else if(a[i]<b[i])
            {
                cout<<"LESS"<<endl;
                break;
            }
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int d;
vector<vector<int>> s(365,vector<int>(26));
vector<int> c(26);

ll calc(vector<int> t){
    ll score=0;
    vector<int> last(26);
    for(int i=0;i<(int)t.size();i++){
        last[t[i]]=i;
        for(int j=0;j<26;j++) score-=c[j]*(i+1-last[j]);
        score+=s[i][t[i]];
    }
    return score;
}

void solve(){
    vector<int> v;
    for(int i=0;i<d;i++){
        ll max_score=-1e9;
        int b=0;
        for(int j=0;j<26;j++){
            v.push_back(j);
            ll score=calc(v);
            if(max_score<score){
                max_score=score;
                b=j;
            }
            v.pop_back();
        }
        v.push_back(b);
    }
    for(int k : v) cout<<k+1<<endl;
}

int main(){
    cin>>d;
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    solve();
}

Measured memory_bytes: 3672
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(K: int, X: int):
    if K*500 >= X:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll H, N;
  cin >> H >> N;
  ll sum = 0;
  rep (i, N) {
    ll a;
    cin >> a;
    sum += a;
  }
  if (sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d,e,f = inpl()
mx = 0
res = 0
ans = 0
for i in range(40):
    for j in range(40):
        water = 100*a*i + 100*b*j
        if water == 0:
            continue
        for k in range(300):
            for l in range(300):
                sugar = c*k + d*l
                if water+sugar > f or sugar > (a*i+b*j)*e:
                    continue
                if sugar/(water+sugar) >= mx:
                    mx = sugar/(water+sugar)
                    res = water+sugar
                    ans = sugar
print(res,ans)

Measured memory_bytes: 68568
from collections import defaultdict
N=int(input())
a=[int(item) for item in input().split()]

dd=defaultdict(int)

for item in a:
  dd[item]+=1


ans=0
for item in set(a):
  if dd[item]>=item:
    ans+=dd[item]-item
  else:
    ans+=dd[item]
print(ans)

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

int main()
{
    int n;
    while (1) {
	cin >> n;
	if (cin.eof()) break;
        int ans = 1;
        for (int i = 1; i <= n; i++)
            ans += i;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<complex>
#include<vector>
#include<algorithm>

#define pb push_back
#define sz size()
using namespace std;

typedef complex<double> P;

namespace std{
  bool operator<(const P &a,const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

double cross(P x,P y){return imag(conj(x)*y);}

vector<P> convex_hull(vector<P> v){
  int n = v.sz;
  sort(v.begin(),v.end());
  vector<P> r;
  for(int i=0;i<n;i++){
    while(r.sz>1 && cross(r[r.sz-1]-r[r.sz-2],v[i]-r[r.sz-1]) <= 0)r.pop_back();
    r.pb(v[i]);
  }
  for(int i=n-2,t=r.sz;i>=0;i--){
    while(r.sz>t && cross(r[r.sz-1]-r[r.sz-2],v[i]-r[r.sz-1]) <= 0)r.pop_back();
    r.pb(v[i]);
  }
  r.pop_back();
  return r;
}

int main(){
  int n;
  vector<P> v;
  P tmp;

  while(scanf("%d",&n),n){
    v.clear();
    for(int i=0;i<n;i++){
      scanf("%lf,%lf",&real(tmp),&imag(tmp));
      v.pb(tmp);
    }

    printf("%d\n",n-(int)convex_hull(v).sz);
  }
}

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

main() {
    int N; cin >> N;
    if(N>=1200) cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	int r;
	cin >> r;
	cout << 3*r*r << endl;
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
void solve(void)
{
    string s;
    cin >> s;
    set<char> st;
    for (auto i : s)
        st.insert(i);
    if (st.size() == 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin >> n >> k;

     cout << n-k+1 << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

// Common memset settings
//memset(memo, -1, sizeof memo); // dp memoization with -1
//memset(arr, 0, sizeof arr); //clear array of integers




int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int a,b;
	cin >> a >> b;


	if(b%a == 0){
		cout << a + b;
	}else{
		cout << b-a;
	}
	

	return 0;
}




Measured memory_bytes: 384
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

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

  ll tle = m;
  ll not_tle = n-m;

  ll tms = 1<<tle;
  ll ans = (not_tle*100 + tle*1900)*tms;

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

// p = 1/2 -> 平均2回試行, p = 1/4 -> 平均4回試行, ...,


Measured memory_bytes: 256