akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X; cin >> X;
    int ans = 0;

    int cnt = X / 500;
    ans += 1000 * cnt;
    X -= 500 * cnt;

    cnt = X / 5;
    ans += 5 * cnt;
    X -= 5 * cnt;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 300005;
const int mod = 998244353;
vector<int>g[maxn];
int n;
int dia() {
    int d[n + 5] = {};
    memset(d, -1, sizeof(d));
    queue<int>q;
    q.push(1);
    d[1] = 0;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (auto i:g[now]) {
            if (~d[i])continue;
            q.push(i);
            d[i] = d[now] + 1;
        }
    }
    int mx = 1;
    f1(n) {
        if (d[i] > d[mx]) {
            mx = i;
        }
    }
    memset(d, -1, sizeof(d));
    //queue<int>q;
    q.push(mx);
    d[mx] = 0;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (auto i:g[now]) {
            if (~d[i])continue;
            q.push(i);
            d[i] = d[now] + 1;
        }
    }
    mx = 0;
    f1(n) {
        mx = max(mx, d[i]);
    }
    return mx + 1;
}
int main(){
    while(cin >> n){
        f1(n) {
            g[i].clear();
        }
        f (n - 1) {
            int x, y;
            cin >> x >> y;
            g[x].pb(y);
            g[y].pb(x);
        }
        int x = dia();
        if (x % 3 == 2) {
            cout << "Second\n";
        }
        else {
            cout << "First\n";
        }
    }
}

Measured memory_bytes: 15988
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int nc = 0;
            int mc = 0;
            int n = 1;
            int m = 1;
            ArrayList<Integer> matrix = new ArrayList<Integer>();
            ArrayList<Integer> vector = new ArrayList<Integer>();
            
            while((line = stdReader.readLine()) != null) {
                // ????????????n??¨m?????????
                if(count == 0) {
                    String[] array = line.split(" ", 0);
                    n = Integer.parseInt(array[0]);
                    m = Integer.parseInt(array[1]);
                    count++;
                    continue;
                }
                
                // ?????????????????????
                if(nc < n) {
                    String[] row = line.split(" ", 0);
                    for(int i = 0; i < m; i++) {
                       matrix.add(Integer.parseInt(row[i]));
                    }
                    nc++;
                    continue;
                }
                
                // ???????????????????????????
                if(mc < m) {
                    vector.add(Integer.parseInt(line));
                    mc++;
                    if(mc != m) {
                        continue;
                    }
                }
                int c = 0;
                for(int i = 0; i < n; i++) {
                    int ans = 0;
                    for(int j = 0; j < m; j++) {
                        ans += matrix.get(c) * vector.get(j);
                        c++;
                    }
                    System.out.println(ans);
                }
                count = 0;
                nc = 0;
                mc = 0;
                matrix.clear();
                vector.clear();
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 27960
#include <iostream>
#include <string>

using namespace std;

bool field[12][12];

void dfs(int x,int y){
	field[x][y]=false;
	if(x!=11&&field[x+1][y]) dfs(x+1,y);
	if(x!=0&&field[x-1][y]) dfs(x-1,y);
	if(y!=11&&field[x][y+1]) dfs(x,y+1);
	if(y!=0&&field[x][y-1]) dfs(x,y-1);
}

int main(void){
	string str;
	int count;
	while(1){
		count=0;
		for(int i=0;i<12;++i){
			cin>>str;
			for(int j=0;j<12;++j){
				field[j][i]=(str[j]-'0'==1)?true:false;
			}
		}
		if(cin.eof()) break;
		
		for(int i=0;i<12;++i){
			for(int j=0;j<12;++j){
				if(field[j][i]){
					dfs(j,i);
					++count;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
int main(void){

    char pic;
    int cards[4][13]={{0}};
    int n,num;
    // 縦にカードの柄0-S,1-H,2-C,3-D、横に数字
    scanf("%d",&n);

    char ch;
    for (int i = 0; i < n; i++){
        scanf("%c",&ch);
        scanf("%c %d",&pic,&num);
        switch (pic)
        {
        case 'S':
            cards[0][num-1]=1;
            break;
        case 'H':
            cards[1][num-1]=1;
            break;
        case 'C':
            cards[2][num-1]=1;
            break;
        case 'D':
            cards[3][num-1]=1;
            break;
        }
    }
    
    for (int i = 0; i < 13; i++){
       if (cards[0][i]==0){printf("S %d\n",i+1);}
        }
    for (int i = 0; i < 13; i++){
       if (cards[1][i]==0){printf("H %d\n",i+1);}
        }
    for (int i = 0; i < 13; i++){
       if (cards[2][i]==0){printf("C %d\n",i+1);}
        }
    for (int i = 0; i < 13; i++){
       if (cards[3][i]==0){printf("D %d\n",i+1);}
        }
        
    
    

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(k>=a){
        k=k-a;
        sum+=a;
    }
    else {
        cout<<k;
        return 0;
    }
    if(k>=b) k=k-b;
    else {cout<<sum<<endl;return 0;}
    if(k>0) {
      
      
        sum-=k;
    }
    cout<<sum<<endl;
    
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

int main(void){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);

    if(a%2==0 || b%2==0){
        printf("Even");
    } else{
        printf("Odd");
    }
    
    
    return 0;
}

Measured memory_bytes: 128
from collections import Counter

n = int(input())
v = tuple(map(int, input().split()))

odds = []
evens = []

for i in range(n):
  if i % 2 == 0:
    evens.append(v[i])
  else:
    odds.append(v[i])

evens_common = Counter(evens).most_common()
odds_common = Counter(odds).most_common()

if evens_common[0][0] != odds_common[0][0]:
  evens_most_count = Counter(evens).most_common()[0][1]
  odds_most_count = Counter(odds).most_common()[0][1]
  print(n - evens_most_count - odds_most_count)
else:
  if len(evens_common) == 1:
    if len(odds_common) == 1:
      print(n//2)
    else:
      print(n - odds_common[1][1])
  else:
    if len(odds_common) == 1:
      print(n - evens_common[1][1])
    else:
      res = min(n - evens_common[1][1] - odds_common[0][1], n - evens_common[0][1] - odds_common[1][1])
      print(res)




Measured memory_bytes: 24800
#include<bits/stdc++.h>
using namespace std;
main()
{
	char s[5];
	int x=700;
	for(int a=1;a<=3;a++) 
	{
		cin>>s[a];
	    if(s[a]==111) x=x+100;
	}
	cout<<x;
	return 0;
} 

Measured memory_bytes: 256
class Dice3():
    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        
        self.dv = [(v[i], v[5-i],
                    ''.join([v[l] for l in ((i+2)%6, (i+4)%6, 5-(i+2)%6, 5-(i+4)%6, (i+2)%6, (i+4)%6, 5-(i+2)%6)]) )
                   for i in  range(6)]
    def IsDifferent(self, d):
        for i in range(6):
            if d[0] != self.dv[i][0] or d[5] != self.dv[i][1]: continue
            if not( ''.join(d[1:3]) in self.dv[i][2]): continue
            p = self.dv[i][2].index( ''.join(d[1:3]) )
            if d[4] != self.dv[i][2][p+2] or d[3] != self.dv[i][2][p+3]: continue
            return False
        return True


dices = [input().split() for n in range(int(input()))]
for i, D1 in enumerate(dices[:-1]):
    d = Dice3(D1)
    for D2 in dices[i+1:]:
        if not d.IsDifferent(D2):
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')

Measured memory_bytes: 7848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  char a,b;
  char res;
  cin >> a>>b;

  if(a=='H') res=b;
  if(a=='D'){
    if(b=='H') res='D';
    if(b=='D') res='H';
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		int n;
		cin >> n;
		int a[n];
		for(int i=0;i<n-1;i++)
		{
			cin >> a[i];
		}
		int x=2;
		vector<int> v[n+2];
		for(int i=0;i<n-1;i++)
		{
			v[a[i]].push_back(x);
			x++;
		}
		for(int i=1;i<=n;i++)
		{
			cout << v[i].size() << endl;
		}
	}
}




Measured memory_bytes: 16104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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


	int ans = 0;
	int l = 0, r = n - 1;
	while (l < r) {
		if (s[l] == 'R') { l++; continue; }
		if (s[r] == 'W') { r--; continue; }

		swap(s[l], s[r]);
		ans++;
		l++;
		r--;
		// cout << s << endl;
	}

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


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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N, Q, A, B;
ll nadd;
map <ll, ll> mmap;
ll x[MAXN];

ll mget (ll loc)
{
    auto it = mmap.upper_bound(loc);
    ll res = abs (it->first - loc) + it->second;
    it--;
    res = min (res, abs (it->first - loc) + it->second);
    return res + nadd;
}

void mput (ll loc, ll val)
{
    if (mget (loc) <= val) return;

    val -= nadd;
    mmap[loc] = val;
    while (true)
    {
        auto it = mmap.upper_bound(loc);
        if (val + abs (it->first - loc) > it->second)
            break;
        mmap.erase(it);
    }

    while (true)
    {
        auto it = mmap.find(loc);
        it--;
        if (val + abs (it->first - loc) > it->second)
            break;
        mmap.erase(it);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);

    mmap[-1e18] = 1e17;
    mmap[1e18] = 1e17;

    cin >> N >> Q >> A >> B;
    for (int i = 0; i < Q; i++)
        cin >> x[i];

    nadd = 0;
    mput (A, abs (x[0] - B));
    mput (B, abs (x[0] - A));

    for (int i = 1; i < Q; i++)
    {
        /*for (auto pp : mmap)
            cout << pp.first << " " << pp.second << "\n";
        cout << nadd << "\n\n";*/

        int cloc = x[i], ploc = x[i-1];

        ll mbest = mget (cloc);

        nadd += abs (cloc - ploc);
        mput (ploc, mbest);
    }

    ll res = 1e18;
    for (auto pp : mmap)
        res = min (res, nadd + pp.second);
    cout << res << "\n";
}

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

#define MAX 25
#define NIL -1

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

struct Node T[MAX];

void print(int u){
    cout << " " << u;
}

void preorder(int u){
    if(u == NIL)    return;

    print(u);
    preorder(T[u].l);
    preorder(T[u].r);
}

void inorder(int u){
    if(u == NIL)     return;

    inorder(T[u].l);
    print(u);
    inorder(T[u].r);
}

void postorder(int u){
    if(u == NIL)     return;

    postorder(T[u].l);
    postorder(T[u].r);
    print(u);
}

int main(){
    int n, id, left, right;
    cin >> n;
    for(int i = 0; i < n; i++){
        T[i].p = NIL;
    }

    for(int i = 0; i < n; i++){
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        if(left != NIL) T[left].p = id;
        if(right != NIL) T[right].p = id;
    }

    int root = 0;
    while(T[root].p != NIL){
        root = T[root].p;
    }

    cout << "Preorder" << endl;
    preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(root);
    cout << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  long long sum=1;
  for(int i=0;i<N;i++){
    if(A.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
    if(sum>1000000000000000000/A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    sum*=A.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3968
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc170_d.cpp"

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

  int n;
  cin >> n;
  map<int, int> mp;
  vi a(n);
  REP(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }

  unique(a);
  int ans = 0;
  vector<bool> table(1e6 + 1, true);
  REP(i, a.size()) {
    if (table[a[i]] && mp[a[i]] == 1) {
      ans++;
    }
    int tmp = a[i];
    while (tmp <= 1e6) {
      table[tmp] = false;
      tmp += a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13716
import math

EPS = 1e-10

class Segment():
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, point):
        # + 演算子での挙動を指定
        return Point(self.x+point.x, self.y+point.y)

    def __sub__(self, point):
        # - 演算子での挙動を指定
        return Point(self.x-point.x, self.y-point.y)

    def __mul__(self, a):
        # * 演算子での挙動を指定
        return Point(a*self.x, a*self.y)

    def __truediv__(self, a):
        # / 演算子での挙動を指定
        return Point(self.x/a, self.y/a)

    def __abs__(self):
        # abs関数での挙動を指定
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2+self.y**2

    def __eq__(self, point):
        # == 演算子での挙動を指定
        return abs(self.x-point.x) < EPS and abs(self.y-point.y) <EPS

def dot(a, b):
    return a.x*b.x+a.y*b.y

def cross(a, b):
    return a.x*b.y - a.y*b.x

def isOrthogonal(a, b):
    return dot(a, b) == 0

def isParallel(a, b):
    return cross(a, b) == 0

def project(s, p):
    #s: Segment(), p: Point()
    base = s.p2 - s.p1
    r = dot(p-s.p1, base)/base.norm()
    return s.p1+base*r

def reflect(s, p):
    return p+(project(s, p)-p)*2

if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    x1, y1, x2, y2 = map(int, input().split())
    s = Segment(Point(x1, y1), Point(x2, y2))

    q = int(input())
    for _ in range(q):
        x0, y0 = map(int, input().split())
        p = Point(x0, y0)
        reflection = reflect(s, p)
        print(reflection.x, reflection.y)



Measured memory_bytes: 5892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    string ans = "";
    rep(i, len(s)) ans += 'x';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def dsum(n):
	res = 0
	while n:
		res += n%10
		n //= 10
	return res

def main():
	N = int(input())
	#S = input().rstrip()
	#N,A,B = map(int,input().split())
	
	res = 1001001001
	t = 0
	for i in range(1,N):
		x = dsum(i)+dsum(N-i)
		if res>x:
			res = x
			t = i

	print(t,N-t,file=sys.stderr)
	print(res)
	
main()


Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}


const int MAXN = 205;
const int MAXK = 20 + 3;

void solve() {
    ll d, t ,s;
    cin >> d >> t >> s;

    if (s * t >= d) cout << "Yes\n";
    else cout << "No\n";

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
//    freopen("../input.in", "r", stdin);
#else

#endif
#ifdef multi
//        gen();
    multisolve();
#else
    solve();
//    gen();
#endif


}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    auto rev = [](string s) {
        REP(i, s.length()) {
            if (s[i] == 'U') s[i] = 'D';
            if (s[i] == 'D') s[i] = 'U';
            if (s[i] == 'R') s[i] = 'L';
            if (s[i] == 'L') s[i] = 'R';
        }
        return s;
    };
    string ans = "";
    REP(y, ty - sy) ans += "U";
    REP(x, tx - sx) ans += "R";
    REP(y, ty - sy) ans += "D";
    REP(x, tx - sx) ans += "L";

    ans += "L";
    REP(y, ty + 1 - sy) ans += "U";
    REP(x, tx + 1 - sx) ans += "R";
    ans += "DR";

    REP(y, ty + 1 - sy) ans += "D";
    REP(x, tx + 1 - sx) ans += "L";
    ans += "U";

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
signed main()
{
    int n;string s;
    cin>>n>>s;
    
    for(int i=1;i<s.size();)if(s[i]==s[i-1])s.erase(begin(s)+i);else i++;
    cerr<<s<<endl;
    cout<<s.size()<<endl;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;

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

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

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

    int N; cin >> N;
    cout << (N+999)/1000 * 1000 - N << endl;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int cnt[500];

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

    int H, W;
    std::cin >> H >> W;
    
    string S[500];
    for(int i=0;i<H;++i){
        std::cin >> S[i];
        for(int j=0;j<W;++j){
            ++cnt[S[i][j] - 'a'];
        }
    }

    int n4 = 0, n2 = 0, n1 = 0;
    if(H % 2 == 0 && W % 2 == 0){
        n4 = (H / 2) * (W / 2);
    }else if(H % 2 == 0 && W % 2 == 1){
        n4 = (H / 2) * (W / 2);
        n2 = H / 2;
    }else if(H % 2 == 1 && W % 2 == 0){
        n4 = (H / 2) * (W / 2);
        n2 = W / 2;
    }else{
        n4 = (H / 2) * (W / 2);
        n2 = H / 2 + W / 2;
        n1 = 1;
    }

    for(int i=0;i<26;++i){
        if(cnt[i] % 2 == 1){
            if(n1 == 0){
                std::cout << "No" << std::endl;
                return 0;
            }

            --n1;
            --cnt[i];
        }
    }

    for(int i=0;i<26;++i){
        if(cnt[i] % 4 == 2){
            if(n2 == 0){
                std::cout << "No" << std::endl;
                return 0;
            }

            --n2;
            cnt[i] -= 2;
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
  std::vector<int> v;
  string xyz ="";
int x=0,y=0,z=0,w=0,i=0,j=0,n=0;
  vector<pair<int, int> > pairs(n);
  std::cin >> x>>y;
  for(i=y-(x-1);i<x+y;i++){
    std::cout << i << ' ';
  }
}


Measured memory_bytes: 256
//Author: nimishkhurana
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define rrep(i,b,a) for(i=b;i>=a;i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int,int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int> 
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define INF 1000000000
template <typename T>
ostream& operator << (ostream& stream, const pair<T,T> &p) {
    return stream<<"("<<p.first<<","<<p.second<<") ";
}

int n;
const int mxn = 1e5;
int h[mxn];
int dp[mxn];

int solve(int i){
    if(i==n-1) return 0;
    if(dp[i]!=-1) return dp[i];
    if(i+1 == n-1)
        return dp[i] = abs(h[i+1] - h[i]);
    
    return dp[i] = min(abs(h[i+1] - h[i]) + solve(i+1), abs(h[i+2] - h[i]) + solve(i+2));
}

int solve_iterative(){
    int dp0 = 0;
    int dp1 = abs(h[1] - h[0]);

    for(int i = 2; i < n; i++){
        int temp = dp0;
        dp0 = dp1;
        dp1 = min(abs(h[i] - h[i-1]) + dp1, abs(h[i-2] - h[i]) + temp);
    }
    return dp1;
}

int main(){
    fastIO
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    memset(dp, -1, sizeof(dp));

    cin>>n;
    for(int i = 0; i < n; i++) cin>>h[i];

    cout<<solve_iterative();
   
    return 0;
}

Measured memory_bytes: 1024
//Kyokai no Kanata //
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;
typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
  const char* comma=strchr(names+1,',');
  cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...)
#endif
float  inf=std::numeric_limits<double>::infinity();
LL INF=std::numeric_limits<LL>::max();
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
map <int,int> M;VI A;
int main()
{
  int n,v;si(n);
  for(int i=0;i<n;i++) si(v),M[v]++;
  for(auto v:M) {
    if(v.S >=4) A.PB(v.F),A.PB(v.F);
    else if(v.S>=2) A.PB(v.F);
  }
  if(A.size()<2) return 0*puts("0");
  int s = A.size();
  printf("%lld\n",1LL*A[s-1]*A[s-2]);
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n; cin >> n;
  vpi job(n);

  rep(i, n) cin >> job[i].se >> job[i].fi;
  sort(all(job));

  /* puts("----------"); */
  /* rep(i, n) cout << job[i].fi << " " << job[i].se << endl; */

  ll now = 0;
  rep(i, n) {
    now += job[i].se;
    if (job[i].fi < now) {
      cout << "No\n";
      return (0);
    }
  }

  cout << "Yes\n";

  return (0);
}


Measured memory_bytes: 4780
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int d=sc.nextInt();
		int n=sc.nextInt();
		double a=0;
		if(n != 100)
		{
			a = n*Math.pow(100,d);
		}
		else
		{
			a = 101*Math.pow(100,d);
		}
		int i = (int)a;
		System.out.print(i);
	}
}

Measured memory_bytes: 25300
function Main(input) {
  var arr = Array.from(input);
  var acgt = ['A','C','G','T'];
  var count = 0;
  var res = [];
  var len = 0;
  var str = '';

  arr.forEach(x => {
    if (acgt.indexOf(x) !== -1) {
      if (res[count] === undefined) {
        res[count] = [];
      }
      res[count].push(x);
    } else {
      count += 1;
    }
  })

  res.forEach(x => {
    var l = x.length;
    if (l > len) {
      len = l;
    }
  })

  console.log(len);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//リニアサーチ 2015／4／22u
#include <iostream>
using namespace std;

bool linear_search(int x, int S[], int N){
	int n = 0;
	while(n < N && S[n] != x){
		n++;
	}
	if(n < N){
		return true;
	}else{
		return false;
	}
}

int main(){
	int n, q, cnt=0;
	cin >> n;
	int S[n];
	for(int i = 0; i < n; i++){
		cin >> S[i];
	}
	cin >> q;
	int T[q];
	for(int i = 0; i < q; i++){
		cin >> T[i];
	}
	for(int i = 0; i < q;i++){
		if(linear_search(T[i],S,n)){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e5 + 10, S2 = 1e7 * 2;

vector<pair<ll, ll>> vec;
vector<ll> cnt, pref;
vector<ll> add[SIZE];

int main() {
    fastInp;

    ll n;
    cin >> n;

    cnt.resize(n);
    pref.resize(n);

    ll curMx = -1, ind = -1;
    vector<ll> k(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        k[i] = a;
        if (curMx < a) {
            vec.push_back({ a, i });
        }
        else {
            
        }
        if (curMx < a) {
            ind = i;
        }
        curMx = max(curMx, a);
    }

    sort(vec.rbegin(), vec.rend());

    curMx = -1, ind = -1;
    for (int i = 0; i < n; i++) {
        ll a;
        a = k[i];
        if (curMx < a) {
        }
        else {
            int l = -1, r = vec.size();
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if (vec[mid].first >= a) {
                    l = mid;
                }
                else {
                    r = mid;
                }
            }
            add[l].push_back(a);
        }
        if (curMx < a) {
            ind = i;
        }
        curMx = max(curMx, a);
    }

    ll curAdd = 0; vec.push_back({ 0, 0 });
    for (int i = 0; i < vec.size() - 1; i++) {
        ll s = 0;
        for (auto cur : add[i]) {
            s += abs(vec[i + 1].first - cur);
        }
        cnt[vec[i].second] += (i + 1 + curAdd) * abs(vec[i].first - vec[i + 1].first) + s;
        curAdd += add[i].size();
    }

    for (int i = 0; i < n; i++) {
        cout << cnt[i] << "\n";
    }
    return 0;
}



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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
string S;
int dp [100001] [26];
const int INF = 1e9;

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

	cin >> S;
	N = S.size();

	fill(dp [0],dp [N + 1],-INF);
	dp [1] [S.front() - 'a'] = 1;
	FOR(i,1,N) FOR(j,0,26){
		if(i != N - 1){
			chmax(dp [i + 1] [j],dp [i] [j] + 1);
		}
		if(S [i] - 'a' != j){
			chmax(dp [i + 1] [S [i] - 'a'],dp [i] [j]);
		}
	}

	int ans = 0;
	FOR(i,0,26){
		chmax(ans,dp [N] [i]);
	}
	printf("%s\n",ans % 2 == 0 ? "First" : "Second");

	return 0;
}


Measured memory_bytes: 10604
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, k, a, b;
    cin >> n >> k;
    map<int,vector<int>> edges;
    int colors[n] = {};
    fill(colors, colors+n, -1);
    for(int i=0;i<n-1;++i)
    {
        cin >> a >> b;
        // make 0-indexed
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    queue<pair<int,pair<int,int>>> q;
    q.push(MP(0, MP(0, 0)));
    while(!q.empty()){
        auto front = q.front();
        int index = front.first;
        int depth = front.second.first;
        int sibling = front.second.second;
        q.pop();
        if(depth == 0) {
            colors[index] = k;
        } else if (depth == 1)
        {
            colors[index] = k - 1 - sibling;
        } else
        {
            colors[index] = k - 2 - sibling;
        }
        int sibling_count = 0;
        for(int i=0;i<edges[index].size();++i)
        {
            if(colors[edges[index][i]] == -1)
            {
                q.push(MP(edges[index][i], MP(depth + 1, sibling_count)));
                sibling_count++;
            }
        }        
    }

    ll res = 1;
    for(int i=0;i<n;++i)
    {
        res *= colors[i];
        res %= 1000000007;
    }
    cout << res << endl;
}

Measured memory_bytes: 13176
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = [LI() for _ in range(2)]
dp = [[0]*N for _ in range(2)]
dp[0][0] = A[0][0]
didj = [[1,0],[0,1]]
for i in range(2):
    for j in range(N):
        for di,dj in didj:
            ni,nj = i+di,j+dj
            if not(0<=ni<=1) or not (0<=nj<=N-1):
                continue
            if ni==0:
                dp[0][nj] = dp[0][nj-1]+A[0][nj]
            elif nj==0:
                dp[1][0] = dp[0][0]+A[1][0]
            else:
                dp[ni][nj] = max(dp[ni-1][nj],dp[ni][nj-1])+A[ni][nj]
            if (ni,nj)==(1,N-1):
                print(dp[-1][-1])
                exit()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;


    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
};


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

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

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int& i : t) {
        cin >> i;
    }
    sort(t.begin(), t.end());
    int bus = 1, j = 0;
    for (int i = 0; i < n; ++i) {
        if (t[i] > t[j] + k or i - j == c) {
            ++bus;
            j = i;
        }
    }
    cout << bus << "\n";
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const double mod = 1e9 + 7;
const ll MAX1E5 = 100000;
const ll MAX1E10 = 10000000000;


int main() {
    int N, a, pool = 0, min = 0, max = 0;
    vector<int> C(8);
    cin >> N;
    REP(i, N) {
        cin >> a;
        a /= 400;
        if (a < 8) {
            C.at(a)++;
        } else {
            pool++;
        }
    }
    REP(i, 8) {
        if (C.at(i) > 0) {
            max++;
        }
    }
    if(max == 0){
        min=1;
    }else{
        min = max;
    }
    max += pool;
    cout << min << " " << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
int mon[6] = {1, 5, 10, 50, 100, 500};
 
int main(){
  int sum = 0,tmp;
 
  for(auto& m : mon){
    std::cin >> tmp;
 
    sum += tmp * m;
  }
 
  std::cout << (sum >= 1000) << std::endl;
}

Measured memory_bytes: 1160
sel='E'

if sel=='A':
    S=input()
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

if sel=='D':
    N,X,Y=map(int,input().split())
    cnt={}
    for k in range(1,N):
        cnt[k]=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            k=j-i # まっすぐ
            k=min(k,abs(i-X)+1+abs(j-Y)) # う回路１
            k=min(k,abs(i-Y)+1+abs(X-j)) # う回路２
            cnt[k]+=1

    for k in range(1,N):
        print(cnt[k])

if sel=='E':
    import heapq
    X,Y,A,B,C=map(int,input().split())
    P=[int(i) for i in input().split()]
    Q=[int(i) for i in input().split()]
    R=[int(i) for i in input().split()]
    P.sort(reverse=True)
    Q.sort(reverse=True)
    red=P[:X]
    gre=Q[:Y]
    heapq.heapify(red)
    heapq.heapify(gre)
    for r in R:
        if red[0]<=gre[0]:
            if red[0]<r:
                heapq.heapreplace(red,r)
        else:
            if gre[0]<r:
                heapq.heapreplace(gre,r)
    print(sum(red)+sum(gre))

Measured memory_bytes: 107884
#include<iostream>
using namespace std;
long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b); 
long long int baikan(long long int a, long long int b, long long int c);
void margesort(int a[], int a_len, int left, int right);
int A[200000], B[200000];
int temp[200000];
int temp2[200000];
int main() {

	//E
	int n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	if (n == 2) {
		cout << 1 << endl;
		cout << 1 << ' ' << 2 << endl;
		return 0;
	}
	cout << n - 1 + (n - 1) * (n - 2) / 2 - k << endl;
	int i,x,y;
	x = n;
	y = n - 1;
	for (i = 0; i < n - 1 + (n - 1) * (n - 2) / 2 - k; i++) {
		cout << x << ' ' << y << endl;
		y--;
		if (y == 0) {
			x--;
			y = x - 1;
		}
	}
	return 0;

	//D
	/*int i, n;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A[i] >> B[i];
	}
	margesort(B, n, 0, n - 1);
	//cout << "Sort" << endl;
	//for (i = 0; i < n; i++) {
	//	cout << A[i] << ' ' << B[i]<< endl;
	//}

	long long int sum = 0;
	for (i = 0; i < n; i++) {
		sum = sum + A[i];
		//cout << sum << ' ' << A[i] << ' ' << B[i] << endl;
		if (sum > B[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;*/

	//C
	/*long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << b - a + 1 - baikan(a, b, c) -  baikan(a, b, d) + baikan(a, b, lcm(c, d)) << endl;
	return 0;*/

	//B
	/*int n, l;
	cin >> n >> l;
	int k = n * l + n * (n - 1) / 2;
	//cout << k;
	int i;
	int min = l;
	for (i = 0; i < n; i++) {
		if (abs(l + i) < abs(min)) {
			min =  l + i;
		}
	}
	cout << k - min << endl;
	return 0;
	*/

	//A
	/*
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
	*/
}

long long int gcd(long long int a, long long int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
long long int lcm(long long int a, long long int b) {
	return a * b / gcd(a, b);
}
long long int baikan(long long int a, long long int b, long long int c) {
	long long int d = b - a + 1;
	if (((b - (d % c)) % c) <= (b % c)) {
		return (d - (d % c)) / c;
	}
	else {
		return (d - (d % c)) / c + 1;
	}
}
void margesort(int a[], int a_len, int left, int right)
{
	int i, j, mid, L, R;

	if (right <= left)
		return;

	mid = (left + right) / 2;
	margesort(a, mid, left, mid);
	margesort(a, a_len - mid, mid + 1, right);

	for (i = left; i <= mid; i++)
	{
		temp[i] = a[i];
		temp2[i] = A[i];
	}
	for (i = mid + 1, j = right; i <= right; i++, j--)
	{
		temp[i] = a[j];
		temp2[i] = A[j];
	}

	L = left;
	R = right;

	for (i = left; i <= right; i++)
	{
		if (temp[L] <= temp[R])
		{
			a[i] = temp[L];
			A[i] = temp2[L];
			L++;
		}
		else
		{
			a[i] = temp[R];
			A[i] = temp2[R];
			R--;
		}
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    string s,t;
  	cin >> s >> t;
    reverse(all(s));
    if(s==t)cout << "YES" << endl;
	else  cout << "NO" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N; cin>>N;
  vector<string> s(N);
  vector<ll> t(N); rep(i,N) cin>>s[i]>>t[i];
  string X; cin>>X;
  
  ll ans=0;
  int judge=0;
  rep(i,N){
    if(judge) ans+=t[i];
    if(s[i]==X) judge=1;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644