akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	auto a = vector<string>(h + 2);
	a[0] = a[h + 1] = string(w + 2, '_');
	for(auto i = 1; i < h + 1; ++i){
		string s;
		cin >> s;
		s = '_' + s + '_';
		a[i] = s;
	}
	int ans = 0;
	auto q = queue<pair<int, int>>();
	for(auto i = 1; i < h + 1; ++i){
		for(auto j = 1; j < w + 1; ++j){
			if(a[i][j] == '#'){
				int d[][2] = { {0, -1}, {1, 0}, {0, 1}, {-1, 0} };
				for(auto t = 0; t < 4; ++t){
					int dx = j + d[t][0];
					int dy = i + d[t][1];
					if(a[dy][dx] == '.'){
						q.push(make_pair(dy, dx));
					}
				}
			}
		}
	}
	while(!q.empty()){
		bool counted = false;
		int size = q.size();
		for(auto k = 0; k < size; ++k){
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			if(a[i][j] == '#') continue;
			if(!counted){
				counted = true;
				++ans;
			}
			a[i][j] = '#';
			int d[][2] = { {0, -1}, {1, 0}, {0, 1}, {-1, 0} };
			for(auto t = 0; t < 4; ++t){
				int dx = j + d[t][0];
				int dy = i + d[t][1];
				if(a[dy][dx] == '.'){
					q.push(make_pair(dy, dx));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9104
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int N=2e5+7;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans;
    a--;
    ll a1=b/c,a2=b/d,a3=b/(c*d/gcd(c,d));
    ll b1=a/c,b2=a/d,b3=a/(c*d/gcd(c,d));
    ll x1=(a1-b1+1),x2=(a2-b2+1),x3=(a3-b3+1);
    ans=b-a+1-x1-x2+x3;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
vector<int> v[100010];
void init()
{
	int x;
	scanf("%d",&x);
	if (x!=1)
	{
		ans++;
	}
	for (int i=2;i<=n;i++)
	{
		scanf("%d",&x);
		v[x].push_back(i);
	}
}
int dfs(int x)
{
	int mx=0;
	for (int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		mx=max(mx,dfs(y));
	}
	if (mx==k-1)
	{
		ans++;
		mx=-1;
	}
	return mx+1;
}
int main()
{
	scanf("%d%d",&n,&k);
	init();
	for (int i=0;i<v[1].size();i++)
	{
		int x=v[1][i];
		for (int j=0;j<v[x].size();j++)
		{
			dfs(v[x][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10368
from sys import stdin

class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k

dlist = DList()

n = int(stdin.readline())
for i in range(n):
    cmd = stdin.readline()
    if   cmd.startswith('insert'):
        dlist.insert(cmd[7:-1])
    elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
    elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
    elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1])

print(' '.join(dlist))



Measured memory_bytes: 227792
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll H,W,h,w;
  cin >> H >> W >> h >> w;
  if(H%h==0&&W%w==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    
    if(W%w!=0){
      ll t=W/w+1;
      rep(i,H){
        rep(j,W){
          if(j%w==0){
            cout << t << " ";
          }else if(j%w==w-1){
            cout << -(t+1) << " ";
          }else{
            cout << 0 << " ";
          }
        }
        cout << endl;
      }
    }else{
      ll t=H/h+1;
      rep(i,H){
        rep(j,W){
          if(i%h==0){
            cout << t << " ";
          }else if(i%h==h-1){
            cout << -(t+1) << " ";
          }else{
            cout << 0 << " ";
          }
        }
        cout << endl;
      }
    }
  }
  
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
using namespace std;
#define NIL -2
#define MAX 100000

struct Node {
	int key;
	int p, l, r;
};


int main() {
	int n;
	cin >> n;

	Node A[MAX];

	//初期化
	for (int m =1;m<= n;m++) {
		A[m].p = NIL;
		A[m].r = NIL;
		A[m].l = NIL;
		A[m].key = NIL;
	}
	//keyをいれる
	int a;
	for (int i = 1; i<=n;i++) {
		cin >> a;
		A[i].key = a;
	}
	//親
	for (int i = 1;i<=n;i++) {
		int b = floor(i / 2);
		if (i == 1) A[i].p = NIL;
		else A[i].p = A[b].key;
	}
	//右の子,左の子
	for (int j = 1; j <= (n / 2);) {
		int c = 2 * j;
		A[j].l = A[c].key;
			int d = 2 * j+1;
			if(d <= n) A[j].r = A[d].key;
		j++;
	}


	for (int k = 1; k<= n;k++) {
		cout << "node " << k << ": " << "key = " << A[k].key << ", ";
		if (int(A[k].p) != NIL) cout << "parent key = " << A[k].p << ", ";
		if (int(A[k].l) != NIL) cout << "left key = " << A[k].l << ", ";
		if (int (A[k].r) != NIL) cout << "right key = " << A[k].r << ", ";
		cout << "\n";
	}
	return 0;
}



Measured memory_bytes: 3108
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

map<int, int> frq;
int h[maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	REP(i, n) {
		cin >> h[i];
		//cout << i - h[i] << " ";
		frq[i - h[i]]++;
	}
	//Acout << endl;
	ll ans = 0;
	REP(i, n) {
		frq[i - h[i]]--;
		//cout << i << " " << h[i] - i << endl;
		ans += frq[h[i] + i];
	}
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 21380
import sys
from io import StringIO
import unittest

def resolve():

    k = int(input())
    s = input()

    if len(s) > k:
        print(s[0:k] + "...")
    else:
        print(s)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """7
nikoandsolstice"""
        output = """nikoand..."""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """40
ferelibenterhominesidquodvoluntcredunt"""
        output = """ferelibenterhominesidquodvoluntcredunt"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 71004
#include "bits/stdc++.h"
using namespace std;
int N;
vector<int>to[100005];

int main() {
	long long x;
	cin >> x;
	long long ans = 0;
	ans += (x / 11) * 2;
	x %= 11;
	if (0 == x) {
	}
	else if (x <=6) {
		ans++;
	}
	else {
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 100006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/

int cl[maxn];
int dist[maxn];

vector<int>g[maxn];
bool vis[maxn];

void solve(int x,int d,int c)
{
   if(cl[x]==0)
   {
     cl[x]=c;
   }
   if(dist[x]>=d)
     return;
   dist[x]=d;
   if(d==0)
    return;
   for(int i=0;i<g[x].size();i++)
   {
     solve(g[x][i],d-1,c);
   }
}


int main()
{
  IOS;
  int n,m;
  cin >> n >> m;
  int a,b;

  for(int i=0;i<m;i++)
  {
     cin >> a >> b;
     g[a].pb(b);
     g[b].pb(a);
  }
  int q;
  cin >> q;
  int v[q],c[q],d[q];
  for(int i=0;i<q;i++)
  {
     cin >> v[i] >> d[i] >> c[i];
  }

  for(int i=q-1;i>=0;i--)
  {
    solve(v[i],d[i],c[i]);
  }

  for(int i=1;i<=n;i++)
     cout << cl[i]<<"\n";
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<ll, ll> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    vector<int> points(n);
    map<int, int> m;
    rep(i, q) {
        int temp;
        cin >> temp;
        temp--;
        m[temp]++;
    }
    rep(i, n) {
        if ((k - (q - m[i])) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

ll D[20005];
int n;
struct box{
    int w, v, s;
    bool operator< (box b){
        return s + w > b.s + b.w;
    }
} B[1005];

int main(){
    fio;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> B[i].w >> B[i].s >> B[i].v;
    }
    sort(B,B+n);
    for(int i = 0; i < n; i++){
        for(int j = B[i].w; j <= B[i].w + B[i].s; j++){
            int k = min(j - B[i].w, B[i].s);
            if(k >= 0) D[k] = max(D[k], D[j] + B[i].v);
        }
    }
    cout << *max_element(D,D+20001) << '\n';
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll Max = max({a, b, c});
	cout << a+b+c-Max << endl;
 	return 0;
}

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

const int INF = (1 << 31) - 1;

struct segtree{
  int size;
  vector<int> dat;
  segtree(int n){
    size = 1;
    while(size < n) size *= 2;
    dat.assign(2 * size - 1, INF);
  }
  void update(int i, int x){
    i += size - 1;
    dat[i] = x;
    while(i > 0){
      i = (i - 1) / 2;
      dat[i] = min(dat[2 * i + 1],dat[2 * i + 2]);
    }
  }
  int find(int a, int b, int k, int l, int r){
    if(b <= l || r <= a) return INF;
    if(a <= l && r <= b) return dat[k];
    int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
};

int main(){
  int n,q;
  scanf("%d %d", &n, &q);
  segtree st(n);
  for(int i = 0; i < q; i++){
    int cmd, x, y;
    scanf("%d %d %d", &cmd, &x, &y);
    if(cmd == 0) st.update(x ,y);
    else if(cmd == 1) printf("%d\n", st.find(x, y + 1, 0, 0, st.size));
  }
  return 0;
}

Measured memory_bytes: 3392
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };
int main(void) {
	int H, W;
	cin >> H >> W;
	vector<string> maze(H);
	for (int i = 0; i < H; i++) cin >> maze[i];

	VVI far(H, vector<int>(W, INF));
	far[0][0] = 0;
	queue<P> q;
	q.push(P(0, 0));
	while (!q.empty()) {
		int now_x = q.front().first;
		int now_y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int next_x = now_x + dx[i];
			int next_y = now_y + dy[i];
			if (next_x < 0 || H <= next_x || next_y < 0 || W <= next_y) continue;
			if (maze[next_x][next_y] == '#') continue;
			if (far[next_x][next_y] != INF) continue;
			far[next_x][next_y] = far[now_x][now_y] + 1;
			q.push(P(next_x, next_y));
		}
	}

	//////////////////解1////////////////////////////////////////
	int ans = 0;
	int forcus_num = 1;//forcus_num
	for (int forcus_num = 1; forcus_num <= H * W; forcus_num++) {
		int count = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (far[i][j] == forcus_num) {
					if (forcus_num > far[H - 1][W - 1]) ans++;			
					else{
						count++;
						if (count >= 2) {
							ans++;
							//far[i][j] = -1*ans;
						}
					}
				}
			}
		}
	}
	//cout << " tmp ans " << ans << endl;
	int num_INF = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze[i][j] != '#') {
				if (far[i][j] == INF) num_INF++;
			}

		}
	}
	//cout << "num_INF : " << num_INF << endl;
	ans += num_INF;

	///////////////////解2////////////////////////////////////////
	//int num_sharp = 0;
	//for (int i = 0; i < H; i++) {
	//	for (int j = 0; j < W; j++) {
	//		if (maze[i][j] == '#') num_sharp++;
	//	}
	//}
	//cout << " num_sharp : " << num_sharp << endl;
	////int ans = H * W - num_sharp - far[H - 1][W - 1]-1;
	//int ans = H * W - num_sharp - (far[H - 1][W - 1]+1);
	//

	if (far[H - 1][W - 1] == INF) {
		cout << "-1" << endl;
		return 0;
	}
	cout << ans << endl;
	/*
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << maze[i][j] << "        ";
		}
		cout << endl;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << far[i][j] << "        ";
		}
		cout << endl;
	}*/
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    unsigned long long int x,y,count = 0;
    scanf("%llu%llu",&x,&y);
    unsigned long long int j = x;
    while (j <= y) {
        j = j * 2;
        count++;
    }
    printf("%llu\n",count);
    return 0;
}

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

class State implements Comparable<State>{
	int a, b;
	public State(int _a, int _b) {
		a = _a; b = _b;
	}
	public int compareTo(State o) {
		return (int)Math.signum(a - o.a);
	}
}

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		State[] arr = new State[N];
		for(int i = 0; i < N; i++) {
			arr[i] = new State(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(arr);
		long cnt = 0;
		int ans = -1;
		for(int i = 0; i < N; i++) {
			cnt += (long)arr[i].b;
			if(cnt >= K) {
				ans = arr[i].a;
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 83856
N, K = map(int, input().split())
S = input()
prev = None
ori = 0
change = 0
for i in range(N):
    if S[i] == prev:
        ori += 1
    elif i != 0:
        change += 1
    prev = S[i]
print(min(ori + change, ori + 2*K))

Measured memory_bytes: 39536
#include <stdio.h>

int main(void) {
  int a, b;
  
  scanf("%d %d", &a, &b);
  
  if (a<b)
  printf("a < b\n");
  else if (a>b)
  	printf("a > b\n");
  else printf("a == b\n");
  
  
	return 0;
}

Measured memory_bytes: 580
import sys

n = int(sys.stdin.readline())
h_list = [int(x) for x in sys.stdin.readline().split()]
h_list[0] -= 1
for i in range(len(h_list)):
    if i == 0:
        continue
    try:
        if h_list[i] > h_list[i - 1]:
            h_list[i] -= 1
        elif h_list[i] == h_list[i - 1]:
            continue
        elif h_list[i] < h_list[i - 1]:
            print("No")
            sys.exit(0)
    except IndexError:
        continue
else:
    print("Yes")


Measured memory_bytes: 14252
use proconio::input;

fn main() {
	input!(a: String);
	input!(b: String);

	let va: Vec<char> = a.chars().collect();
	let vb: Vec<char> = b.chars().collect();

	if va.len() > vb.len() {
		println!("GREATER");
		return;
	}
	if va.len() < vb.len() {
		println!("LESS");
		return;
	}

	for i in 0..va.len() {
		if va[i] > vb[i] {
			println!("GREATER");
			return;
		}
		if va[i] < vb[i] {
			println!("LESS");
			return;
		}
	}
	println!("EQUAL");
}


Measured memory_bytes: 2172
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:40:38 2020

@author: black
"""


S = list(input())

len = 0
ans = 0
for i in S:
    if i == "A" or i == "T" or i == "C" or i == "G":
        len += 1
        ans = max(len, ans)
    else:
        len = 0
print(ans)

Measured memory_bytes: 2940
#include<stdio.h>
int main(){
  int i,j,n;
  scanf("%d",&n);
  int a[n+1];
  long long int b[n+1];
  for(i=1;i<=n;i++){
    b[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  	b[a[i]]++;
  }
  long long int sum=0;
  for(i=1;i<=n;i++)
    sum+=(b[i]-1)*b[i]/2;
  for(i=0;i<n;i++)
    printf("%lld\n",sum-b[a[i]]+1);
  return 0;
}

Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_11_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<int> s;

            for (int i = 0 ; i < (1 << n) ; i++)
            {
                s = new List<int>(n);
                for (int j = 0 ; j < n ; j++)
                {
                    if ((i >> j & 1) == 1) s.Add(j);
                }
                Console.WriteLine("{0}:{1}",i, (s.Count == 0 ? "":" ") + string.Join(" ", s.Select(x => x.ToString()).ToArray()));
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    for(int i=0; i<N; ++i) cin >> B[i];

    long long num = 0, cnt1 = 0, cnt2 = 0;
    for(int i=0; i<N; ++i) {
        if(A[i] > B[i]) cnt1 += A[i] - B[i];
        else cnt2 += (B[i] - A[i] + 1) / 2;
        num += B[i] - A[i];
    }
    
    if(num >= max(cnt1, cnt2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=105;
char s[N];int c[26],c1,c2,n,m;
inline int min(R int x,R int y){return x<y?x:y;}
int main(){
	scanf("%d%d",&n,&m);
	fp(i,1,n){
		scanf("%s",s+1);
		fp(j,1,m)++c[s[j]-'a'];
	}
	c1=(n>>1)*(m>>1),c2=(n&1)*(m>>1)+(m&1)*(n>>1);
	for(R int k,i=0;c1&&i<26;++i){
		k=min(c1,c[i]>>2);
		c1-=k,c[i]-=(k<<2);
	}
	if(c1)return puts("No"),0;
	for(R int k,i=0;c2&&i<26;++i){
		k=min(c2,c[i]>>1);
		c2-=k,c[i]-=(k<<1);
	}
//	printf("%d %d\n",c1,c2);
	if(c2)return puts("No"),0;
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

struct edge{
  int to,id;
};

vector<vector<edge>>g;
vector<int>ans;

void dfs(int v,int c=-1,int p=-1){
  int k=1;
  for(int i=0;i<g[v].size();i++){
    int u=g[v][i].to,ei=g[v][i].id;
    if(u==p){continue;}
    if(k==c){k++;}
    ans[ei]=k;k++;
    dfs(u,ans[ei],v);
  }
}
int main() {
  int N;
  cin>>N;
  g.resize(N);
  ans=vector<int>(N-1);
  for(int i=0;i<N-1;i++){
    int a,b;cin>>a>>b;a--;b--;
    g[a].emplace_back((edge){b,i});
    g[b].emplace_back((edge){a,i});
  }
  dfs(0);
  int mx=0;
  for(int i=0;i<N;i++){
    mx=max(mx,int(g[i].size()));
  }
  cout<<mx<<endl;
  for(int i=0;i<N-1;i++){
    cout<<ans[i]<<endl;
  }
  return 0;  
}

Measured memory_bytes: 10976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long int max(std::vector<long long int> v){
    int maxVal = 0;
    for(int i = 0; i < (long long int)v.size(); ++i) {
        if( v[i] > maxVal )
            maxVal = v[i];
    }
    return maxVal;
}

int main(){
    long long int n,m;
    long long int po[52][52]={};
    cin >> n;
    cin >> m;
    for(long long int i=0;i<m;i++){
        long long int p,q;
        cin >> p >>q;
        po[p][q]++;
        po[q][p]++;
    }
    for(int i=1;i<=n;i++){
        long long int sum=0;
        for(int j=1;j<51;j++){
            sum+=po[i][j];
        }
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int m = 1;
	REP(i, n - 1) {
		if (a[i] != a[i + 1]) {
			m++;
		}
	}
	vector<int>b(m, 1);
	int count = 0;
	REP(i, m) {
		for (int j = count; j < n - 1; j++) {
			if (a[j] == a[j + 1]) {
				b[i]++;
				count++;
			}
			else {
				break;
			}
		}
		count++;
	}
	sort(b.begin(), b.end());
	int ans = n;
	REP(i, k) {
		ans -= b[m - 1 - i];
		if (ans <= 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int ar[4];
  for(int i = 0; i < 4; i++){
    cin >> ar[i];
  }
  sort(ar, ar+4);
  if(ar[0] == 1 && ar[1] == 4 && ar[2] == 7 && ar[3] == 9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int N,bN,fx=0;
    cin >> N;
    bN=N;

    while(1){
        fx+=N%10;
        N/=10;
        if(N<10){
            fx+=N;
            break;
        }
    }

    if(bN%fx==0){
        cout << "Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
num=int(input())
youso_list=input().split(' ')
boolean=True

for youso in youso_list:
    magic_num=0
    youso=int(youso)
    if youso%2!=0:
        continue
    
    if youso%3!=0:
        magic_num+=1
        
    if youso%5!=0:
        magic_num+=1
    
    if magic_num==2:
        boolean=False
        break

if boolean==False:
    print('DENIED')

elif boolean==True:
    print('APPROVED')

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
   int A, B;
   cin >> A >> B;
   
   if (A%2 == 1 && B%2 == 1) cout << "Yes" << endl;
   else cout << "No" << endl;
   
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;
//const ll INF = 1ll << 60;
const int INF = 1001001001;
vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableFromN[2505];
bool ok[2505];

void dfs(int v)
{
    if (reachableFrom1[v])
        return;
    reachableFrom1[v] = true;
    for (int u : to[v])
    {
        dfs(u);
    }
}

void rdfs(int v)
{
    if (reachableFromN[v])
        return;
    reachableFromN[v] = true;
    for (int u : rto[v])
    {
        rdfs(u);
    }
}

int main()
{

    int n, m, p;
    cin >> n;
    cin >> m;
    cin >> p;
    vector<tuple<int, int, int>> edges;

    REP(i, m)
    {
        int a, b, c;
        cin >> a;
        cin >> b;
        cin >> c;

        --a;
        --b;
        c -= p;
        c = -c;
        edges.emplace_back(a, b, c);
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(n - 1);
    REP(i, n)
    ok[i] = reachableFrom1[i] & reachableFromN[i];

    { //bellman-ford
        vector<int> d(n, INF);
        d[0] = 0;
        bool upd = true;
        int step = 0;
        while (upd)
        {
            upd = false;

            REP(i, m)
            {
                int a, b, c;
                tie(a, b, c) = edges[i];
                if (!ok[a])
                    continue;
                if (!ok[b])
                    continue;
                int newD = d[a] + c;
                if (newD < d[b])
                {
                    upd = true;
                    d[b] = newD;
                }
            }
            step++;
            if (step > n)
            {
                puts("-1");
                return 0;
            }
        }
        int ans = -d[n - 1];
        ans = max(ans, 0);
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
	int i,len;
	char io[22],xio[22];
	fgets(io,sizeof(io),stdin);
	len=strlen(io)-1;
	io[len]='\0';
	for(i=0;i<len;i++){
		xio[len-1-i]=io[i];
	}
	xio[i]='\0';
	for(i=0;i<len;i++){
		printf("%c",xio[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 520
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,k,l,r;
    string s,p;
    cin>>s>>p;
    n=s.size();
    m=p.size();
    l=INT_MAX;
    for(i=0;i+m<=n;i++)
    {
        r=0;
        for(j=i,k=0;k<m;j++,k++)
        {
            if(s[j]!=p[k])
            {
                r++;
            }
        }
        l=min(l,r);
    }
    cout<<l<<"\n";
    return 0;
}



Measured memory_bytes: 3644
K=int(input())
D={}
for i in range(1,10**4):
    for j in range(12):
        Sunuke=str(i)+("9"*j)
        if len(Sunuke)<=15 and Sunuke not in D:
            S=0
            for k in range(len(Sunuke)):
                S+=int(Sunuke[k])
            D[int(Sunuke)]=S
D=list(D.items())
D.sort()
#print(D[:10])
import bisect

d=[10**16 for i in range(len(D))]
d[0]=0
ans=[0 for i in range(len(D))]
for i in range(len(D)):
    ans[bisect.bisect_right(d,D[i][0]/D[i][1])]=D[i][0]
    d[bisect.bisect_right(d,D[i][0]/D[i][1])]=D[i][0]/D[i][1]
    
#print(ans[:50])
ANS=[]
MAX=0
for i in range(len(ans)):
    if ans[i]>MAX:
        ANS.append(ans[i])
        MAX=ans[i]
#print(ANS[:100])
for i in range(K):
    print(ANS[i])
#print(d[:10])

Measured memory_bytes: 20404
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    vector<string> s;
    forn(i, 3) {
        string cur;
        cin >> cur;
        s.pb(cur);
    }
    int turn = 0;
    while (sz(s[turn])) {
        auto x = s[turn].begin();
        char aux = *x;
        s[turn].erase(x);
        turn = aux - 'a';
        //cout << s[0] << " " << s[1] << " " << s[2] << " " << turn << " " << aux << endl;
    }
    char ans[] = {'A', 'B', 'C'};
    cout << ans[turn] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a[100][100], b[100][100];
	long long int c[100][100];
	int n, m, l, i, j, k;
	cin >> n >> m >> l;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	for (i = 0; i < 100; i++) {
		for (j = 0; j < 100; j++) {
			c[i][j] = 0;
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			for (k = 0; k < m; k++) {
				c[i][j] += (a[i][k] * b[k][j]);
			}
		
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			cout << c[i][j] ;
			if (j != l - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
/**
 *    Author  : Ador
 *    Created : 24.07.2020
**/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cctype>
typedef long long int ll ;
typedef unsigned long long int ull ;
using namespace std ;
int main(void)
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
        //freopen("input.txt", "r", stdin) ;
        //freopen("output.txt", "w", stdout) ;
    int i , x ,track ;
    for(i = 1 ; i <= 5 ; ++i)
    {
        cin >> x ;
        if(!x) track = i ;
    }
    cout << track << "\n" ;
    return 0 ;
}


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

#define SPADE 0
#define HEART 1
#define CLUB 2
#define DIA 3
#define TYPE_NUM 4
#define CARD_NUM 13

int pow2(int num) {
	int x = 1;
	for (int i = 1; i < num; i++) {
		x *= 2;
	}
	return x;
}

int main() {
	int n,num;
	char type;
	short card[TYPE_NUM] = {0,0,0,0};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> type >> num;
		switch (type) {
		case 'S':   card[SPADE] |= pow2(num); break;
		case 'H':   card[HEART] |= pow2(num); break;
		case 'C':   card[CLUB] |= pow2(num); break;
		case 'D':   card[DIA] |= pow2(num); break;
		}
	}
	for (int i = 0; i < TYPE_NUM; i++) {
	    int x = 0x1;
		for (int j = 1; j <= CARD_NUM; j++) {
			if (!(card[i] & x)) {
				switch (i) {
				case SPADE: type = 'S'; break;
				case HEART: type = 'H'; break;
				case CLUB:  type = 'C'; break;
				case DIA:   type = 'D'; break;
				}
				cout << type << " " << j << endl;
			}
			x *= 0x2;
		}
	}
	return 0;
}

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

using namespace std;

int main() {
    int n, t, a;
    cin >> n >> t >> a;

    int ans = -1;
    int diff = INT32_MAX;
    for (int i = 1; i <= n; ++i) {
        int h;
        cin >> h;

        int tmp = abs(1000 * (t - a) - 6 * h);
        if (tmp < diff) {
            diff = tmp;
            ans = i;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
ll n,s=0; cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
{
    cin>>a[i];
}
for(ll i=0;i<n;i++)
{
    for(ll j=i+1;j<n;j++){
    s+=a[i]*a[j];
}
}
cout<<s<<endl;
}


Measured memory_bytes: 3612
n = int(input())

xy = [[] * n for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        xy[i].append((x, y))

ans = 0
def judge(f):
    for i in range(n):
        if flag[i] == 1:
            for j in xy[i]:
                if f[j[0] - 1] != j[1]:
                    return False
        
    return True

for i in range(2 ** n):
    flag = [0] * n
    for j in range(n):
        if i >> j & 1:
            flag[j] = 1
    if judge(flag):
        ans = max(ans, sum(flag))
print(ans)

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

int main(){
	int i,a,b,c;
	for(i = 0;i < 3;++i){
		cin >> a;
		if(i == 0) b = a;
		else{
			if(a < b) b = a;
		}

	}
	for(i = 0;i < 2;++i){
		cin >> a;
		if(i == 0) c = a;
		else {
			if(a < c) c = a;
		}
	}
	cout << b + c - 50 << endl;
	return 0;
}

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


void solve(long long N){
    if(N % 2 == 0) cout << N/2 << endl;
    else cout << N/2 + 1 << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
int main() {
	int N; cin >> N;
	vector<pair<int, int> >A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
	sort(A.begin(), A.end(), pairCompare);
	cout << A[N - 1].first + A[N - 1].second << endl;
}

Measured memory_bytes: 1024
from operator import mul
from functools import reduce

N,M=map(int,input().split())
P=10**9+7
ans=1

def Pdeco(m):
    ret=[]
    for i in range(2,int((M)**(0.5))+100):
        if m<=i:
            if m!=1: ret.append(int(m))
            break
        elif i>int((M)**(0.5)+50):
            ret.append(m)
            break

        while m%i==0:
            m=m//i
            ret.append(i)
    return ret


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

L=Pdeco(M)
nums=set(L)

for n in nums:
    p=L.count(n)
    ans=(ans*cmb(N+p-1,N-1))%P

print(ans)

Measured memory_bytes: 3684
N = int(input())
c_list = [s == "R" for s in input().strip()]

count_R = 0
count_W = 0
for s in c_list:
	if s:
		count_R += 1
	else:
		count_W += 1

tobemoved_R = 0
tobemoved_W = 0
for i, s in enumerate(c_list):
	if i < count_R:
		if not s:
			tobemoved_R += 1
	else:
		if s:
			tobemoved_W += 1

print(max(tobemoved_R, tobemoved_W))


Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    n *= 1000;
    int64_t res = 0;
    if(d<2*s && d<4*h && d<8*q){
        res += (n/2000) * d;
        n -= 2000 * (n/2000);
    }
    if(s<2*h && s<4*q){
        res += (n/1000) * s;
        n -= 1000 * (n/1000);
    }
    if(h<2*q){
        res += (n/500) * h;
        n -= 500 * (n/500);
    }
    res += (n/250) * q;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;

typedef long long ll;

vector<ll> vec1, vec2;
ll n;

int main()
{
    ios::sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n;

    for (int i = 0; i < n; ++i) {
        ll temp;
        cin >> temp;
        if (i == 0) {
            vec1.push_back(temp);
        }
        else {
            vec1.push_back(vec1.back() + temp);
        }
    }

    for (int i = 0; i < n; ++i) {
        ll temp;
        cin >> temp;
        if (i == 0) {
            vec2.push_back(temp);
        }
        else {
            vec2.push_back(vec2.back() + temp);
        }
    }

    ll ans = vec1[0] + vec2[n - 1];

    for (int i = 1; i < n; ++i) {

        ans = max(ans, vec1[i] + vec2[n - 1] - vec2[i - 1]);

    }

    cout << ans;

    return 0;

}

Measured memory_bytes: 256
from collections import defaultdict

S = input()
d = defaultdict(int)

for i in range(len(S)):
  d[S[i]] += 1

ma = max(d["a"], d["b"], d["c"])
mi = min(d["a"], d["b"], d["c"])

if ma-mi > 1:
  print("NO")
else:
  print("YES")

Measured memory_bytes: 3444
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100005;
const int N = maxn * 60;
vector<int> v[maxn];
int n, m, root1[maxn], root2[maxn], lc[N], rc[N], a[maxn], tot;
LL siz[N], nxt[N], cur[N], qsiz, qnxt, qcur;
void change(int &x, int y, int l, int r, LL c, LL n) {
    x = ++tot;
    lc[x] = lc[y];
    rc[x] = rc[y];
    siz[x] = siz[y] + 1;
    nxt[x] = nxt[y] + n;
    cur[x] = cur[y] + c;
    if (l == r) return;
    else {
        int mid = (l + r) >> 1;
        if (n <= mid) change(lc[x], lc[y], l, mid, c, n);
        else change(rc[x], rc[y], mid + 1, r, c, n);
    }
}
void query(int x, int y, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) {
        qsiz += siz[y] - siz[x];
        qnxt += nxt[y] - nxt[x];
        qcur += cur[y] - cur[x];
    }
    else {
        int mid = (l + r) >> 1;
        if (ll <= mid) query(lc[x], lc[y], l, mid, ll, rr);
        if (rr > mid) query(rc[x], rc[y], mid + 1, r, ll, rr);
    }
}
void query(int *root, int l1, int r1, int l2, int r2) {
    qsiz = qnxt = qcur = 0;
    if (l1 > r1 || l2 > r2) return;
    query(root[l1 - 1], root[r1], 1, m, l2, r2);
}
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i < n; ++i)
        v[a[i]].push_back(a[i+1]);
    for (int i = 1; i <= m; ++i) {
        root1[i] = root1[i-1];
        root2[i] = root2[i-1];
        for (auto &x : v[i]) {
            if (x < i) change(root1[i], root1[i], 1, m, i, x);
            else change(root2[i], root2[i], 1, m, i, x);
        }
    }
    LL tmp, ans = 1e16;
    for (int i = 1; i <= m; ++i) {
        tmp = 0;
        query(root1, 1, i - 1, 1, m);       tmp += qnxt + qsiz * (m - i + 1);
        query(root2, 1, i - 1, i, m);       tmp += qnxt + qsiz * (1 - i);
        query(root2, 1, i - 1, 1, i - 1);   tmp += qnxt - qcur;
        query(root1, i, m, i, m);           tmp += qnxt + qsiz * (1 - i);
        query(root1, i, m, 1, i - 1);       tmp += qnxt + qsiz * m - qcur;
        query(root2, i, m, 1, m);           tmp += qnxt - qcur;
        ans = min(ans, tmp);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 72832
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    string s;
    cin >> s;
    if((s.at(2) == s.at(3)) && (s.at(4) == s.at(5))) YES
    else NO
}

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

int main(void) {
	int k, x;
	cin >> k >> x;
	for (int i = x-k+1; i < x+k; i++) {
		if (i == x+k) cout << i << endl;
		else cout << i << " ";
	}
	return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        n: usize,
        m: usize,
        a: [usize; m],
    }
    let s: usize = a.into_iter().sum();
    if s > n {
        println!("-1");
    } else {
        println!("{}", n - s);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 2268
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    ll n;
    cin >> n;

    map<ll, ll> mp;
    rep (i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }

    vector<ll> use;

    for (auto x: mp) {
        if (x.second >= 4) {
            rep (i, 2) use.push_back(x.first);
        }
        else if (x.second >= 2) use.push_back(x.first);
    }
    
    sort(use.rbegin(), use.rend());
    cout << (use.size() < 2 ? 0 : use[0] * use[1]) << endl;
    return 0;
}


Measured memory_bytes: 6528
import java.util.*;
import static java.util.Comparator.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		LinkedList<Pair2> list = new LinkedList<>();
		
		for(int i = 0; i < n; i++) {
			int x = scan.nextInt();
			int l = scan.nextInt();
			list.add(new Pair2(x-l,x+l));
		}
		scan.close();
		
		list.sort(comparing(Pair2::getSecond));
		int num = 0;
		int x = Integer.MIN_VALUE;
		for(Pair2 p : list) {
			if(x <= p.first) {
				x = p.second;
				num++;
			}
		}
		
/*		while(!list.isEmpty()) {
			int x = list.removeFirst().second;
			list = list.stream().filter(pair -> pair.first >= x).collect(Collectors.toCollection(LinkedList::new));
			num++;
		}*/
		System.out.println(num);
	}
}

class Pair2 {
	int first; 
	int second;
	
	public Pair2(int first, int second) {
		this.first = first;
		this.second = second;
	}
	
	public int getSecond() {
		return second;
	}
	
	public String toString() {
		return first + ":" + second;
	}
}

Measured memory_bytes: 94352
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N);
	map<int, int>m;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		m[v[i]] = i;
	}
	vector<int>box(N + 1);
	box[N] = 1;
	for (int i = N - 1; i > 0; i--) {
		if (m[i] < m[i + 1]) {
			box[i] = box[i + 1] + 1;
		}
		else {
			box[i] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, box[i]);
	}
	cout << N - ans << endl;
	return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <math.h>

int main(){
  int n, d, c;
  long x, y;
  double a;
  std::cin >> n >> d;
  c = 0;
  for(int i=0; i<n; i++){
    std::cin >> x >> y;
    a = sqrt(x*x+y*y);
    if(a <= (double)d) c++;
  }
  std::cout << c << std::endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;
  cout << "2018" << s.substr(4,6) << endl;
}



Measured memory_bytes: 256
def main():
    N,K=map(int,input().split())
    h=[]
    for i in range(N):
        a=int(input())
        h.append(a)
    
    h.sort()
    result=10**10
    count=0
    for i in range(N-K+1):
        count=h[i+K-1]-h[i]
        result=min(result,count)
    print(result)
if __name__=="__main__":
    main()

Measured memory_bytes: 7384