akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
// const ll INF = 1LL << 30;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

int main() {
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];

    ll mo = 1000;
    rep(i, 0, n-1){
        if(a[i] < a[i+1]){
            ll di = a[i+1] - a[i];
            ll c = mo/a[i];
            mo += di*c;
        }
    }
    co(mo);

    return 0;
}



Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  string s;
  cin>>s;
  cout<<(s[0]-'0')+(s[1]-'0')+(s[2]-'0')<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,p,a;
	bool odd=false;
	cin>>n>>p;
	while(cin>>a)
		if(a%2==1)
			odd=true;
	cout<<(odd?(long long)pow(2,n-1):(1-p)*(long long)pow(2,n))<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int main(){
	DRI(n);
	DRI(p);int t=-1,ans=1;//is increasing
	REP(i,n-1){
		DRI(x);
		if(t==-1){
			if(x>p)t=1;
			else if(x<p)t=0;
		}
		else{
			if(t){
				if(x<p)t=-1,ans++;
			}
			else{
				if(x>p)t=-1,ans++;
			}
		}
		p=x;
	}
	printf("%d",ans);
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
cnt=0
count=0
for i in range(n):
            if a[i]%2 !=0:
                        print(0)
                        exit()
            else:
                        for k in range(10**6):
                                    for i in range(n):
                                                if a[i]%2 ==0:
                                                            cnt+=1
                                                            #print('cnt1',cnt)
                                                            a[i]=a[i]//2
                                                            #print(a)
                                                            if cnt==n:
                                                                        count+=1
                                                                        cnt=0
                                                                        #print('cnt',cnt,'count',count)
                                                else:
                                                            print(count)
                                                            exit()
                                                
            


Measured memory_bytes: 3060
import math
# s=int(input())
b=input()
c=[]
for i in b:
    c.append(i)
#a = list(map(int,input().split()))
#b = list(map(int,input().split()))

a1=c[c.index("A"):]
a2=[i for i, x in enumerate(a1) if x=="Z"]
print(len(a1[:a2[-1]+1]))

Measured memory_bytes: 17660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	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
}
int main()
{
 ll n;
 cin>>n;
 ll digit = n%10;
 if(digit==2||digit==4||digit==5||digit==7||digit==9)
 cout<<"hon";
 else if(digit==3)
 cout<<"bon";
 else
 cout<<"pon";




return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100005], b[100005], c[100005];
ll dp[100005][3];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i < 3; i++) {
		dp[0][i] = 0;
	}
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i];
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
	}
	int max = -1e5;
	for (int i = 0; i < 3; i++) {
		if (dp[n][i] > max) {
			max = dp[n][i];
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void rs(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int k,a,b,c;
int main(){
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int ans=0;
    int x=min(k,a);
    k-=x;
    ans+=x;
    x=min(k,b);
    k-=x;
    x=min(k,c);
    ans-=x;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
      std::string str; cin >> str;
      set<char> se;
      for(char s:str){
        se.insert(s);
      }
      int ascii_a = 'a';
      for(int a = 0;a < 26;a++){
        if(se.find(ascii_a + a) == se.end()){
          char s = ascii_a + a;
          cout<<s<<endl;
          return 0;
        }

      }
      cout<<"None"<<endl;
      return 0;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector <pair<pair<string, int>, int>> list(N);
  string s;
  int p;
  for (int i = 0; i < N; i++) {
    cin >> s >> p;
    list.at(i) = make_pair(make_pair(s, -p), i + 1);
  }
  sort (list.begin(), list.end());
  for (int i = 0; i < N; i++) {
    cout << list.at(i).second << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()

    if N == 1: print("Hello World")
    else:
        A = INT()
        B = INT()
        print(A + B)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int,int>>hogen;
	for (int i = 0;i < n;++i) {
		int a,b;
		cin >> a >> b;
		hogen.push_back(make_pair(a, b));
	}
	vector<pair<int, int>>hogem;
	for (int i = 0;i < m;++i) {
		int c, d;
		cin >> c >> d;
		hogem.push_back(make_pair(c, d));
	}
	for (int i = 0;i < n;++i) {
		vector<int>hoge;
		for(int q = 0;q < m;++q){
			int tmp = abs(hogen[i].first - hogem[q].first) + abs(hogen[i].second - hogem[q].second);
			hoge.push_back(tmp);
		}
		sort(hoge.begin(), hoge.end());
		for (int q = 0;q < m;++q) {
			int tmp = abs(hogen[i].first - hogem[q].first) + abs(hogen[i].second - hogem[q].second);
			if (tmp == hoge[0]) {
				cout << q + 1 << endl;
				goto ok;
			}
		}
	ok:;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
   int a,b,tmp,c=0;
   scanf("%d%d",&a,&b);
   if(3>a){
        return 1;
   }else if(b>20){
        return 1;
   }

        if(a<b){
                tmp=a;
                a=b;
                b=tmp;
        }
        c=a;
        a=a-1;

        if(a<b){
                tmp=a;
                a=b;
                b=tmp;
        }
        c=c+a;
        printf("%d\n",c);
        return 0;
}


Measured memory_bytes: 128
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int n;
vector<vector<int> > graph(200000, vector<int>());
vector<int> parent(200000, -1);
vector<int> nodenum(200000, -1);
vector<long long int> result(200000, -1);
vector<long long int> result2(200000, -1);
vector<long long int> fact(200010, 1);

void setFact() {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
}

long long int getpow(int x, int n) {
	if (n == 0) return 1;
	long long int tmp = getpow(x, n / 2);
	long long int res = (tmp * tmp) % mod;
	if (n % 2 == 1) res = (res * x) % mod;
	return res;
}

void setParent(int now) {
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == parent[now]) continue;
		parent[next] = now;
		setParent(next);
	}
}

int getNodeNum(int now) {
	if (nodenum[now] > 0) return nodenum[now];
	nodenum[now] = 1;
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == parent[now]) continue;
		nodenum[now] += getNodeNum(next);
	}
	return nodenum[now];
}

long long int getResult(int now) {
	if (result[now] >= 0) return result[now];
	int nodenumSum = getNodeNum(now) - 1;
	result[now] = fact[nodenumSum];
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == parent[now]) continue;
		result[now] *= getResult(next);
		result[now] %= mod;
		result[now] *= getpow(fact[getNodeNum(next)], mod - 2);
		result[now] %= mod;
	}
	return result[now];
}

int getResult2(int now) {
	if (result2[now] >= 0) return result2[now];
	if (now == 0) return result2[0] = getResult(0);
	int p = parent[now];
	long long int ans = getResult2(p);
	// nowを根とする部分木のぶんを削ぎ落とす
	ans *= fact[getNodeNum(now)];
	ans %= mod;
	ans *= getpow(getResult(now), mod - 2);
	ans %= mod;
	ans *= fact[n - 1 - getNodeNum(now)];
	ans %= mod;
	ans *= getpow(fact[n - getNodeNum(now)], mod - 2);
	ans %= mod;
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == p) continue;
		ans *= getResult(next);
		ans %= mod;
		ans *= getpow(fact[getNodeNum(next)], mod - 2);
		ans %= mod;
	}
	return result2[now] = ans;
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	setParent(0);
	setFact();
	for (int i = 0; i < n; i++) {
		cout << getResult2(i) << endl;
	}
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    unordered_map<ll,ll> mp;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        ++mp[A[i]];
        ans += A[i];
    }

    ll Q;
    cin >> Q;
    while (Q--) {
        ll b,c;
        cin >> b >> c;
        if (mp.find(b) == mp.end()) {
            cout << ans << "\n";
            continue;
        }
        ans += mp[b] * (c - b);
        mp[c] += mp[b];
        mp.erase(b);

        cout << ans << "\n";
    }

}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 7364
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N,M;

	cin >> N >> M;

	int sum[100010]={};
	for(int i=0;i<M;i++)
	{
		int L,R;
		cin >> L >> R;
		
		sum[L]++;
		sum[R+1]--;
	}

	int ans=0;
	for(int i=1;i<=N;i++)
	{
		sum[i]+=sum[i-1];
		if(sum[i]==M)
			ans++;
	}

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



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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static String line;

	static int index(char c) {
		if ('a' <= c && c <= 'z') return c - 'a';
		return 26 + c - 'A';
	}

	static boolean satisfy(String clause) {
		String[] vars = clause.split("&");
		boolean[][] used = new boolean[2][52];
		for (String var : vars) {
			int pos = var.length() - 1;
			int i = index(var.charAt(pos));
			if (used[1 - pos][i]) return false;
			used[pos][i] = true;
		}
		return true;
	}

	static boolean solve() {
		String[] clause = line.split("\\|");
		for (String c : clause) {
			if (satisfy(c.substring(1, c.length() - 1))) return true;
		}
		return false;
	}

	public static void main(String[] args) throws Exception {
		while (true) {
			line = sc.next();
			if (line.equals("#")) break;
			System.out.println(solve() ? "yes" : "no");
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <math.h>

int main(){
  int H, W;
  long long int ans;
  scanf("%d %d", &H, &W);

  if(H == 1 || W == 1){
    ans = 1;
  }else{
    ans = (long long int)ceil((double)H * (double)W / 2.0);
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	if (A.length() != B.length()) {
		if (A.length() > B.length()) cout << "GREATER" << endl;
		else cout << "LESS" << endl;
	}
	else {
		if (A > B) cout << "GREATER" << endl;
		else if (A < B) cout << "LESS" << endl;
		else cout << "EQUAL" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[120];
long double var[30];
char str[210];
int cur;
long double expr();
long double term(){
	if('0'<=str[cur]&&str[cur]<='9'){
		long double ret=0.0L;
		while('0'<=str[cur]&&str[cur]<='9'){
			ret*=10.0L;ret+=(long double)(str[cur++]-'0');
		}
		return ret;
	}
	if(str[cur]=='('){
		cur++;
		long double ret=expr();
		cur++;
		return ret;
	}
	if('a'<=str[cur]&&str[cur]<='z'){
		long double ret=var[str[cur]-'a'];
		cur++;
		if(str[cur]=='^'){
			cur++;
			int po=str[cur]-'0';cur++;
			long double val=1.0L;
			for(int i=0;i<po;i++)val*=ret;
			ret=val;
		}
		return ret;
	}
}
long double fact(){
	long double ret=term();
	while(str[cur]=='*'||(str[cur]!='+'&&str[cur]!='-'&&str[cur]&&str[cur]!=')')){
		if(str[cur]=='*')cur++;
		long double tmp=term();
	//	printf("%Lf * %Lf = %Lf\n",ret,tmp,ret*tmp);
		ret*=tmp;
	}
//	printf("%d %Lf\n",cur,ret);
	return ret;
}
long double expr(){
	long double ret=fact();
	while(str[cur]=='+'||str[cur]=='-'){
		cur++;
		char ch=str[cur-1];
		long double tmp=fact();
		if(ch=='+')ret+=tmp;
		else ret-=tmp;
	}
	return ret;
}
long double ABS(long double a){return max(a,-a);}
int main(){
	while(1){
		gets(in);
		if(in[0]=='.')break;
		int at=0;
		for(int i=0;in[i];i++){
			if(in[i]==' '&&i&&'0'<=str[at-1]&&str[at-1]<='9'&&'0'<=in[i+1]&&in[i+1]<='9'){
				str[at++]='*';
			}
			if(in[i]!=' ')str[at++]=in[i];
		}
		while(1){
			gets(in);
			if(in[0]=='.')break;
			str[at]='-';
			str[at+1]='(';
			int ind=at+2;
			for(int i=0;in[i];i++){
				if(in[i]==' '){
					if(i&&'0'<=str[ind-1]&&str[ind-1]<='9'&&'0'<=in[i+1]&&in[i+1]<='9'){
						str[ind++]='*';
					}
					continue;
				}
				str[ind++]=in[i];
			}
			str[ind++]=')';
			str[ind]=0;
			bool ok=true;
			for(int i=0;i<500;i++){
				for(int j=0;j<26;j++)var[j]=(long double)(rand()%1000)/200;
				cur=0;
				long double res=expr();
				if(ABS(res)>0.5L){
		//			printf("%s %Lf %Lf\n",str,var[23],res);
					ok=false;break;
				}
			}
			if(ok)printf("yes\n");
			else printf("no\n");
		}
		printf(".\n");
	}
}

Measured memory_bytes: 920
/* 133a */
#include<stdio.h>
#include<math.h>
int main(void)
{
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  if(n*a>b){
    printf("%d\n",b);
  }
  if(n*a<=b){
    printf("%d\n",n*a);
  }
  return 0;
}


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

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

using namespace std;

void init_graph(int nx, int ny, vector<vector<int>>& graph) {
  auto n = graph.size();

  for (auto f = 0; f < nx; ++f) {
    for (auto t = f + 1; t <= nx; ++t) {
      auto diff = t - f;
      graph[f][t] = diff;
    }
  }

  auto ring_len = ny - nx + 1;
  auto xymax = ring_len / 2;
  for (auto f = nx; f < ny; ++f) {
    for (auto t = f + 1; t <= ny; ++t) {
      auto diff = t - f;
      graph[f][t] = (diff <= xymax) ? diff : (ring_len - diff);
    }
  }

  for (auto f = ny; f < n - 1; ++f) {
    for (auto t = f + 1; t <= n - 1; ++t) {
      auto diff = t - f;
      graph[f][t] = diff;
    }
  }
}

int min_path(int i, int j, int nx, int ny, vector<vector<int>>& graph) {
  if (i <= nx && nx <= j && j <= ny) {
    return graph[i][nx] + graph[nx][j];
  } else if (nx <= i && i <= ny && ny <= j) {
    return graph[i][ny] + graph[ny][j];
  } else if (i <= nx && ny <= j) {
    return graph[i][nx] + graph[nx][ny] + graph[ny][j];
  } else {
    return graph[i][j];
  }
}

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  auto graph = vector<vector<int>>(n, vector<int>(n, 0));
  auto nx = x - 1;
  auto ny = y - 1;
  init_graph(nx, ny, graph);

  auto vec = vector<int>(graph.size() - 1);
  rep(i, n - 1) {
    for (auto j = i + 1; j < n; ++j) {
      auto len = min_path(i, j, nx, ny, graph);
      vec[len - 1]++;
    }
  }

  for (auto t : vec) {
    cout << t << endl;
  }
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

vector<vi> A;
ll N;
vi b;

int main()
{
    A = vector<vi>(3, vi(3));
    REP(i, 3)
    {
        REP(j, 3)
        {
            cin >> A[i][j];
        }
    }
    cin >> N;
    b = vi(N);
    REP(i, N)
    {
        cin >> b[i];
    }

    auto X = vector<vi>(3, vi(3));
    REP(k, N)
    {
        REP(i, 3)
        {
            REP(j, 3)
            {
                if (A[i][j] == b[k])
                {
                    X[i][j] = 1;
                }
            }
        }
    }
    string ans = "No";
    REP(i, 3)
    {
        if (X[i][0] == 1 and X[i][1] == 1 and X[i][2] == 1)
        {
            ans = "Yes";
        }
        if (X[0][i] == 1 and X[1][i] == 1 and X[2][i] == 1)
        {
            ans = "Yes";
        }
    }
    if (X[0][0] == 1 and X[1][1] == 1 and X[2][2] == 1)
    {
        ans = "Yes";
    }
    if (X[0][2] == 1 and X[1][1] == 1 and X[2][0] == 1)
    {
        ans = "Yes";
    }
    OUT(ans);
}


Measured memory_bytes: 256
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = 40;

int n;

int A[MAXN + 5][MAXN + 5];

inline void input()
{
	auto safe_getc = [] ()
	{
		register char ch(getc());
		while(!isdigit(ch)) ch = getc();
		return ch;
	};

	n = read<int>() * 2;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			A[i][j] = safe_getc() - '0';
}

int vis[MAXN + 5][MAXN + 5][MAXN + 5];
LL f[MAXN + 5][MAXN + 5][MAXN + 5];

inline LL F(int l, int i, int r)
{
	if(l == i && i == r) return 1;
	if(l > r || i <= l || i >= r) return 0;
	if(vis[l][i][r]) return f[l][i][r];

	LL &res = f[l][i][r];
	vis[l][i][r] = 1, res = 0;
	for(int j = l; j < i; ++j) for(int k = i + 1; k <= r; ++k) if(A[j][k])
		for(int p = j; p < i; ++p) for(int q = i + 1; q <= k; ++q)
			res += F(l, j, p) * F(p + 1, i, q - 1) * F(q, k, r);
	return res;
}

inline void solve()
{
	LL ans = 0;
	for(int i = 2; i <= n; ++i) if(A[1][i]) ans += F(2, i, n);
	printf("%lld\n", ans);
}

int main()
{
#ifdef K_ON
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




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

int main() {
    int n, x;
    while(true) {
        cin >> n >> x;
        int count = 0;
        if(n == 0 && x == 0) {
            break;
        }
        for(int i = 1; i < x/3 && i <= n-2; i++) {
            for(int j = i + 1; j < x - (i + j) && j <= n-1 ; j++) {
                if(x - i - j <= n) {
                    count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}


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

int main(int argc, char *argv[])
{
    int t, p, r, tid, pid, time, score, team;
    string msg;
    while (cin >> t >> p >> r, t) {
        vector<int> ans(t + 1, 0);
        vector<int> penalty(t + 1, 0);
        vector<vector<int> > wrong(t + 1, vector<int>(p + 1, 0));
        for (int i = 0; i < r; ++i) {
            cin >> tid >> pid >> time >> msg;
            if (msg[0] == 'W') {
                wrong[tid][pid]++;
            } else {
                ans[tid]++;
                penalty[tid] += 1200 * wrong[tid][pid] + time;
            }
        }
        for (int i = 0; i < t; ++i) {
            score = -1;
            for (int j = t; j > 0; --j) {
                if (score < ans[j]) {
                    score = ans[j];
                    team = j;
                } else if (score == ans[j]) {
                    team = (penalty[team] < penalty[j]) ? team : j;
                }
            }
            cout << team << ' ' << score << ' ' << penalty[team] << endl;
            ans[team] = -2;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
import math
from functools import reduce
k = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            q = [a, b, c]
            ans += gcd_list(q)

print(ans)


Measured memory_bytes: 69600
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()

if s == 'SAT':
    print(1)
elif s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)


Measured memory_bytes: 39664
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long

const ll mod = 1e9+7;
const int maxn = 200005;
ll f[maxn],inv[maxn];
int N;

ll Pow(ll a,ll b)
{
	ll ans=1;
	while(b){
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

void init()
{
	f[0]=1;
	for(int i=1;i<=N;i++){
		f[i]=f[i-1]*i%mod;
	}
	inv[0]=1;
	inv[N]=Pow(f[N],mod-2);
	for(int i=N-1;i>0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}

ll C(int a,int b)
{
	if(a<0||b<0) return 1;
	return f[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
    ll n,m,a,b;
	scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
	N=n+m-2;
	init();
	ll ans=C(n+m-2,n-1);
	for(ll i=1;i<=b;i++){
		ans-=C(n-a+i-2,n-a-1)*C(a-1+m-i,a-1);
		ans=(ans%mod+mod)%mod;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b)cout<< "a < b" << endl;
	else if(a>b)cout << "a > b" <<endl;
	else cout << "a == b"<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int a[8],t,b=0;
    for(int i=0;i<8;i++) a[i]=0;
    while(n--){
    	scanf("%d",&t);
    	if(t<3200) a[t/400]++;
    	else b++;
	}
	int ans=0;
	for(int i=0;i<8;i++) if(a[i]) ans++;
	if(!ans) printf("1");
	else printf("%d",ans);
	printf(" %d\n",ans+b);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

bool sortBySec(const pair<int, LL> &a, const pair<int, LL> &b) {
  return a.second > b.second;
}

int main(void){
  int n, m;
  cin >> n >> m;
  vector<LL> a(n);
  vector<pair<int, LL> > bc(m);

  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  rep(i, m) cin >> bc[i].first >> bc[i].second;
  sort(bc.begin(), bc.end(), sortBySec); // O(MlogM)

  int cnt = 0;
  vector<LL> d(n);
  rep(i, m) {
    for (int j = 0; j < bc[i].first; j++) {
      d[cnt] = bc[i].second;
      cnt ++;
      if (cnt == n) break;
    }
    if (cnt == n) break;
  }

  LL sum = 0;
  rep(i, n) {
    if (d[i] < a[i]) sum += a[i];
    else sum += d[i];
  }

  cout << sum << endl;

  return 0;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while (cur != nil && cur->key != key) {
      cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void _delete(int key){
    deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = (NodePointer)malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  x->prev = nil;
  nil->next = x;
  
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	_delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 34444
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma once
#include<bits/stdc++.h>
#define q register

using namespace std;

int ans;

string s;

inline void Qspeed()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int main()
{
	Qspeed();
	cin>>s;
	ans=s.length()-2;
	cout<<s[0]<<ans<<s[s.length()-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
keys = []

for _ in range(M):
    cost, _ = map(int, input().split())
    mask = 0
    for i in map(int, input().split()):
        mask |= (1 << (i - 1))
    keys.append((cost, mask))

dp = [[float('inf')] * (1 << N) for _ in range(M + 1)]
dp[0][0] = 0

for i, (cost, mask) in enumerate(keys, start=1):
    for state in range(1 << N):
        dp[i][state] = min(dp[i - 1][state], dp[i][state])
        dp[i][state | mask] = min(dp[i - 1][state] + cost, dp[i][state | mask])

ans = dp[M][(1 << N) - 1]
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 138456
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	int in[1000]; //inµÄ¢é©Ç¤©
	int stay[1000]; //ØÝJnÔ
	int sum[1000];	//vØÝÔ
	int out;
	int n;
	int nowday, nowmon;
	
	while( cin >> n, n)
	{
		memset( in, 0, sizeof(in));
		memset( stay, 0, sizeof(stay));
		memset( sum, 0, sizeof(sum));
		out = 0;
		
		for(int i = 0 ; i < n ; i++ )
		{
			int mt, dy, hr, mn, id, stime;
			char c, io;
			
			cin >> mt >> c >> dy;
			cin >> hr >> c >> mn;
			cin >> io;
			cin >> id;
			
			stime = hr*60 + mn;
			
			if( io == 'I' )
			{
				in[id] = 1;
				stay[id] = mn + 60*hr;
			}
			else
			{
				if( id == 0 )
				{
					for(int j = 0; j < 1000; j++ )
					{
						if( in[j] == 1)
						{
							sum[j] += min( stime - stay[j], stime - stay[0] );
						}
					}
				}
				else
				{
					if(in[0] == 1)
					{
						sum[id] += min( stime - stay[id], stime - stay[0] );
					}
				}
				
				in[id] = 0;
			}
			
		}
			
		for( int i = 1; i < 1000 ; i++ )
		{
			if( sum[i] > out )
			out = sum[i];
		}
		
		cout << out << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 0
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define all(x) x.begin(),x.end()


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vll v(n);
	ll j = 0;
	For(i, 0, n) {
		cin >> v[i];
		j = v[i] ^ j;
	}
	For(i, 0, n) {
		ll c = j ^ v[i];
		cout << c << " ";
	}


	return 0;
}


Measured memory_bytes: 4740
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int y = sc.nextInt();
        System.out.println(y % 1000 == 0 ?  0 : 1000-(y%1000));
    }
    
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25388
import sys
readline = sys.stdin.readline
from operator import itemgetter

def main():
    N = int(readline())
    AB = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]
    AB.sort(key=itemgetter(1))
    t = 0
    for a, b in AB:
        t += a
        if t > b:
            print('No')
            return
        
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 31832
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	vector <bool> has(n);
	vector <int> cnt(n);

	forn(i, m) {
		int x;
		string s;
		cin >> x >> s;
		x--;
		if (s == "AC") {
			has[x] = true;
		}
		else {
			if (!has[x])
				cnt[x]++;
		}
	}

	int ans = 0, p = 0;
	forn(i, n) {
		ans += has[i];
		if (has[i])
			p += cnt[i];
	}
	cout << ans << " " << p;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int id;
		double omosa, takasa, BMI;
		String data, dataperson[];
		while( sc.hasNext()) {
			data = sc.next();
			dataperson = data.split(",",3);
			id = Integer.valueOf(dataperson[0]);
			omosa = Double.valueOf(dataperson[1]);
			takasa = Double.valueOf(dataperson[2]);
			if(omosa/(takasa*takasa)>=25.0) System.out.println(id);
		}
	}

}


Measured memory_bytes: 26104
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;
 
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;
 
template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);
 
struct edge{int to, cost;};
 
class Graph
{
public:
    int V;
    vector<vector<edge>> G;
 
    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }
 
    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }
 
    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }
 
    void erase_edge(int from, int to){
        vec e(0);
        REP(i, G[from].size()){
            if(G[from][i].to == to) e.push_back(i);
        }
        IREP(i, e.size()) G[from].erase(G[from].begin() + e[i]);
    }
 
    void erase_edge2(int v1, int v2){
        erase_edge(v1, v2);
        erase_edge(v2, v1);
    }

    bool dfs(int v, vector<bool> &tmp_used, vector<bool> &used){
        REP(k, G[v].size()){
            if(tmp_used[G[v][k].to]) return true;
            tmp_used[G[v][k].to] = true;
            used[G[v][k].to] = true;
            if(dfs(G[v][k].to, tmp_used, used)) return true;
            tmp_used[G[v][k].to] = false;
        }
        return false;
    }
};
 
 
 
signed main(){
 
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;
    vec ab(N);
    REP(i, N){
        if(s[i] == 'A'){
            ab[i] = 1;
        }else{
            ab[i] = 0;
        }
    }
    Graph G(2 * N);
    vec a(M), b(M);
    REP(i, M){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if(ab[a[i]] == ab[b[i]]){
            G.add_edge(a[i], b[i] + N, 0);
            G.add_edge(b[i], a[i] + N, 0);
        }else{
            G.add_edge(a[i] + N, b[i], 0);
            G.add_edge(b[i] + N, a[i], 0);
        }
    }
 
    bool ans = false;
    vector<bool> tmp_used(2 * N, false), used(2 * N, false);
    REP(i, 2 * N){
        if(used[i]) continue;
        used[i] = true;
        tmp_used[i] = true;
        if(G.dfs(i, tmp_used, used)) ans = true;
        tmp_used[i] = false;
    }


    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}
 
 
template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 27396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = 1e18;
int main(){ 
  ld a, b;
  cin >> a >> b;
  ld res = a * b;
  cout << (ll)res << endl;
  return 0;
} 

Measured memory_bytes: 3728
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
ll int d[200000];
vector<ll int> v;

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

    REP(i, N){
        int tmp;
        scanf("%d", &tmp);
        v.push_back(tmp);
      	d[i] = tmp;
    }

    sort(v.begin(), v.end());

    int p = v[N/2 - 1];
    int q = v[N/2];

    REP(i, N){
        if(d[i] <= p) printf("%d\n", q);
        else printf("%d\n", p);
    }

	return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (1 == B) cout << 0;
	else {
		int ans = 1;
		int tmp = A;
		while (tmp < B) {
			++ans;
			tmp += A - 1;
		}
		cout << ans;
	}
}

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

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);
        final int t = scanner.nextInt();

        for (int i = 0; i < t; i++) {
            final int n = scanner.nextInt();
            final int k = scanner.nextInt();
            final int[] distances = new int[n - 1];
            int previous = scanner.nextInt();
            for (int j = 0; j < n - 1; j++) {
                final int current = scanner.nextInt();
                distances[j] = current - previous;
                previous = current;
            }
            Arrays.sort(distances);
            int total = 0;
            for (int j = 0; j < n - k; j++) {
                total += distances[j];
            }
            System.out.println(total);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

int main()
{
    int k, n;
    cin >> k >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = a[n] - a[1];
    for (int i = 2; i <= n; i++)
        ans = min(ans, k - a[i] + a[i - 1]);
    cout << ans;
}

Measured memory_bytes: 1024