akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

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

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

struct BIT {
	typedef ll input_t;

	vector<input_t> bit_;
	const long long n_;

	BIT(long long n) :n_(n) {
		bit_.resize(n + 1LL, 0);
	}

	input_t sum(int i) {
		input_t s = 0;
		while (i > 0) {
			s += bit_[i];
			i -= i & (-i);
		}
		return s;
	}

	void add(int i, input_t x) {
		while (i <= n_) {
			bit_[i] += x;
			i += (i & (-i));
		}
	}
};


struct BSearch {
	static ll solve(ll left, ll right, function<ll(ll)> pred) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			if (pred(middle)) {
				right = middle;
			}
			else {
				left = middle;
			}
		}
		return right;
	}
};

static ll lpow(ll v, ll c) {
	ll a = 1;
	rep(i, c) {
		a *= v;
	}
	return a;
}

typedef tuple<ll, ll, ll> t3;

static t3 split(ll v) {
	ll x = 0;
	ll y = 0;
	ll c = 0;
	int i = 0;
	while (v > 0) {
		if (v % 3 == 1) {
			x |= 1LL << i;
			c++;
		}
		else if (v % 3 == 2) {
			y |= 1LL << i;
			c++;
		}
		i++;
		v /= 3;
	}
	return { x,y,c };
}

int main() {
	ll h, w, d;
	cin >> h >> w >> d;
	ll d2 = d * 2;
	rep(y, h) {
		rep(x, w) {
			int x2 = x - y + 1000;
			int y2 = x + y + 1000;
			x2 %= d2;
			y2 %= d2;
			if (x2 < d && y2 < d) {
				cout << "R";
			}
			if (x2 >= d && y2 < d) {
				cout << "G";
			}
			if (x2 < d && y2 >= d) {
				cout << "Y";
			}
			if (x2 >= d && y2 >= d) {
				cout << "B";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3572
while True:
    x, y = map(int, input().split())
    if x == y == 0:
        break
    for i in range(x):
        for j in range(y):
            if i == 0 or i == x - 1 or j == 0 or j == y - 1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7008
N=int(input())
A=list(map(int,input().split()))
import heapq

X=A[:N]
Y=[-i for i in A[2*N:]]
heapq.heapify(X)
heapq.heapify(Y)
x=sum(X)
y=-sum(Y)
XMA=[0]*(N+1)
YMI=[0]*(N+1)
XMA[0]=x
YMI[N]=y
for i in range(N):
  heapq.heappush(X,A[N+i])
  s=heapq.heappop(X)
  x+=A[N+i]-s
  XMA[i+1]=x
  
  heapq.heappush(Y,-A[2*N-1-i])
  t=-heapq.heappop(Y)
  y+=A[2*N-1-i]-t
  YMI[N-i-1]=y
  
ANS=[0]*(N+1)
for i in range(N+1):
  ANS[i]=XMA[i]-YMI[i]
print(max(ANS))

Measured memory_bytes: 37212
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
int a[25][25];

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i, m) cin >> b[i];

  int ans = 0;
  vector<int> sm(n, c);
  rep(i, n) {
    rep(j, m) {
      cin >> a[i][j];
      a[i][j] *= b[j];
      sm[i] += a[i][j];
    }
  }

  rep(i, n) {
    if (sm[i] > 0) ans++;
  }
  cout << ans;

  return 0;
}


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

int main(){
	for(;;){
		int H,W;
		cin>>H>>W;
		if(H==0&&W==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

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

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

    vector<int> X(N);
    rep(i,N) cin >> X[i];

    sort(X.begin(), X.end());
    int min=X[0];
    int max=X[N-1];

    ll min_power=LLONG_MAX;
    for (int x = min; x <= max; x++) {
        ll power=0;
        for (int i = 0; i < N; i++) {
            power=power+pow((X[i]-x),2);
        }
        if (min_power>power) {
            min_power=power;
        }
    }

    cout << min_power << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	string s; cin >> s;
	int n = s.length();
	int c = 0;
	for (int i = 0; i < (n + 1)/2; i++) {
		if (s[i] != s[n - i - 1]) { c++; }
	}

	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
int main(){
	int n;
	cin >>n;
	int ans=0;
	vector<long long>a(n,0);
	vector<long long> b(n , 0);
	vector<long long>d(n,0);
	for(int i=0;i<n;i++){
		cin >>a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
		d[i] = a[i] - b[i];
	}

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

	long long qu=0;
	int at=0;
	//for (int i = 0; i < n; i++)
	//{
	//	cout<<d[i]<<endl;
	//}
	while(d[at] <0){
		qu+=d[at];
		at++;
		ans++;
	}
	//cout<<qu<<endl;
	//cout<<ans<<endl;
	at=n-1;
	
	while(d[at] >0 and qu <0){
		qu+=d[at];
		
		ans++;
		at--;
	}
	if(qu <0){
		ans=-1;
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  if (B == 1)
    cout << 0 << endl;
  else {
    cout << ceil((long double)(B - 1) / (A - 1)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String ans = "NO";
        int A = sc.nextInt(), B = sc.nextInt(), X = sc.nextInt();
        if(B >= X - A && X >= A)
             ans = "YES";
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var culture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
            while (true)
            {
                var a = ReadInts();
                if (a[0] == 0)
                {
                    return;
                }
                var day = new DateTime(2004, a[0], a[1]);
                WriteLine(day.ToString("dddd", culture));
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 16324
#include<stdio.h>

int main (){
	
	int number;
  	scanf("%d", &number);
  	
	long long int arr[number], max = 1e18, prod = 1, flag = 0, zero = 0; //1e18 = 10^18
	// flag utk nandain kalau sum nya >1e18 atau tidak
  
  for (int i = 0; i < number; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}





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

int main(){ //できたじゃねーかよーーー。個数を持つのね。なるほど。
int n,q;
cin >> n;
vector<int> cnt(100010);
ll sum=0;
rep(i,n){
    int a;
    cin >> a;
    cnt[a]++;
    sum +=a;
}
vector<ll> s(100010);
cin >> q;
rep(i,q){
    int b,c;
    cin >> b >> c;
    cnt[c] += cnt[b];
    s[i]= sum + (c-b)*cnt[b];
    cnt[b]=0;
    sum = s[i];
    //cout << s[i] << endl; これでOKだけど，入力をコピペで入れると変になるよ。
}

rep(i,q) cout << s[i] << endl;

}

Measured memory_bytes: 4540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int m = n % 2 == 1 ? n - 1 : n;
			List<Tuple<int, int>> a = new List<Tuple<int, int>>();
			for (int i = 1; i <= m / 2; i++) {
				a.Add(new Tuple<int, int>(i, m - i + 1));
			}

			long count = 0;
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < a.Count; i++) {
				for (int j = i + 1; j < a.Count; j++) {
					sb.AppendLine($"{a[i].Item1} {a[j].Item1}");
					sb.AppendLine($"{a[i].Item1} {a[j].Item2}");
					sb.AppendLine($"{a[i].Item2} {a[j].Item1}");
					sb.AppendLine($"{a[i].Item2} {a[j].Item2}");
					count += 4;
				}
			}

			if (n % 2 == 1) {
				for (int i = 0; i < m; i++) {
					sb.AppendLine($"{i + 1} {n}");
				}

				count += m;
			}

			Console.WriteLine(count);
			Console.WriteLine(sb.ToString());
		}
	}

	
}


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

struct Node{
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

Node *root, *NIL;

void inorder(Node *T){
    if (T == NIL)
        return;
    inorder(T->left);
    cout << ' ' << T->key;
    inorder(T->right);
}

void preorder(Node *T){
    if (T == NIL)
        return;
    cout << ' ' << T->key;
    preorder(T->left);
    preorder(T->right);
}

void infree(Node *T){
    if (T == NIL)
        return;
    infree(T->left);
    delete T;
    infree(T->right);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while (x != NIL){
        y = x;
        if (x->key < z->key)
            x = x->right;
        else
            x = x->left;
    }
    z->parent = y;
    if (y == NIL)
        root = z;
    else if (z->key > y->key)
        y->right = z;
    else
        y->left = z;
}

int main(){
    int m;
    cin >> m;
    string s;
    int k;
    for (int i = 0; i < m; i++){
        cin >> s;
        if (s == "insert"){
            cin >> k;
            insert(k);
        }
        else if (s == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    infree(root);
    return 0;
}


Measured memory_bytes: 26624
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<map>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<string>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define For(i,N) for(ll i=0;i<N;i++)
int main()
{
	ll N;
	cin >> N;
	vector<int>a(N+1);
	rep(N) {
		cin >> a[i+1];
	}
	vector<int>ans(N + 1,-1);

	map<int, int>cnt;
	for (int i = N; i >= 1; i--) {
		int c = 0;
		for (int j = 2; i * j <= N; j++) {
			c += ans[i * j];
		}
		c += a[i];
		ans[i] = c % 2;
		if (ans[i] == 1)
			cnt[i]++;
	}
	cout << cnt.size()<<endl;
	for (auto it = cnt.begin(); it != cnt.end(); it++) {
		cout << it->first << " ";
	}
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<ll,ll> pl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define nl "\n"
#define rep(i,n) for(int i=0; i<(n); i++)
#define sortup(v) sort(v.begin(), v.end())
#define sortdown(v) sort(v.rbegin(), v.rend())

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

    // solution comes here

    ll N;   cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    sortdown(A);

    ll small=0, large=0;
    rep(i, N-1) {
        if(A[i]==A[i+1]) {
            small = large;
            large = A[i];
            i++;
        }
        if(small*large) break;
    }

    cout << small * large << nl;
}

Measured memory_bytes: 1024
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！
  //未定義動作に気を付ける！！
  //DPや二分探索の範囲に気をつける！！

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

  vec b(m);
  REP(i,m) cin >> b[i];
  int ans = 0;

  REP(_,n){
    vec a(m);
    REP(i,m) cin >> a[i];
    int cnt = c;
    REP(i,m) cnt += a[i]*b[i];
    if(cnt > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>

int main(void) {
  int n;
  std::string s;

  std::cin >> n;
  std::cin >> s;

  const char* str = s.c_str();
  size_t max = 0;

  std::unordered_set<char> set;
  for (size_t i = 0; i < n; i++) {
    set.clear();
    size_t count = 0;
    for (size_t j = 0; j < i; j++) {
      for (size_t k = i; k < n; k++) {
        if (str[j] == str[k]) {
          auto pair = set.emplace(str[j]);
          if (pair.second) {
            count++;
          }
        }
      }
    }
    if (count > max) {
      max = count;
    }
  }

  std::cout << max << std::endl;;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define forsaken
#ifdef forsaken
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
#else
  #define dbg(...)
#endif
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#define IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
	inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
ll a,b;
ll solve(ll n)
{
    ll res=0;
    if((n-n/2)%2==1)res+=1;
    ll t=2;
    while(t<=n)
    {
        if((n-t+1)/t%2==0&&(n-t+1)%t%2==1)res+=t;
        t<<=1;
    }
    return res;
}
int main()
{
    scanf("%lld%lld",&a,&b);
    if(a==b)printf("%lld\n",a);
    else
    {
        if(a==0)a++;
        if(b==0)b++;
        printf("%lld\n",solve(a-1)^solve(b));
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int count = 0;
     for (int i = 0; i <= 5; i++) {
    if (s.at(i) == '1') {
      count++;
    }
  }cout << count << endl;
     
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    ll n;
    cin >> n;
    n++;
    VI a;
    while (n){
        a.push_back(n%2);
        n /= 2;
    }
    reverse(ALL(a));
    int m = a.size();
    // REP(i,m) cout << a[i];
    // cout << endl;
    deque<int> ans;
    int x = 1;
    FOR(i,1,m-1){
        ans.push_back(x++);
        if (a[i]) ans.push_front(x++);
    }

    cout << ans.size() * 2 << endl;
    FOR(i,1,ans.size()) cout << i << " ";
    while (!ans.empty()){
        cout << ans.front() << " ";
        ans.pop_front();
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
li = [0]*(10**5+10)

for i in A:#出現する個数の管理
    li[i] += 1

ans = sum(A)#

for i in range(Q):
    B,C = map(int,input().split())
    ans += li[B]*C - li[B]*B
    print(ans)
    li[C] += li[B]#個数を追加する
    li[B] = 0#置換されたAnは必ず0となる

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

int n;
char s[155], t[155];

int main() {
	scanf("%d", &n);
	scanf("\n%s", s);
	scanf("\n%s", t);
	
	int res = n + n;
	
	for (int i = 0; i < n; i++) {
		bool bad = false;
		
		for (int j = i; j < n; j++) {
			if (s[j] != t[j - i]) {
				bad = true;
			}
		}
		
		if (!bad) {
			res = i + n;
			break;	
		}
	}
	
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int X = nextInt();
        int Y = nextInt();

        //We also consider the case in which there are only cranes or only turtles.
        if(Y<2*X){
            System.out.println("No");
            return;
        }
        if((Y-2*X)%2 == 1){
            System.out.println("No");
            return;
        }

        int turtle = (Y-2*X)/2;
        if(turtle > X){
            System.out.println("No");
            return;
        }
         
        System.out.println("Yes");
        return;
        
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32540
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def graph_input(N, M):
    G = [[] for _ in range(N + 1)]
    for _ in range(M):
        a, b = map(int, readline().split())
        G[a].append(b)
        G[b].append(a)
    ind = np.cumsum(list(map(len, G)), dtype=np.int32)
    G = np.concatenate(G).astype(np.int32)
    return G, ind

def main(N, G, ind, V, D, C):
    # 強さ n で塗った時刻
    dp = np.full((N + 1, 11), -1, np.int32)
    for t in range(len(V)):
        v, d = V[t], D[t]
        dp[v, d] = t
    for n in range(10, 0, -1):
        for v in range(1, N + 1):
            dp[v, n - 1] = max(dp[v, n - 1], dp[v, n])
            for i in range(ind[v - 1], ind[v]):
                w = G[i]
                dp[w, n - 1] = max(dp[w, n - 1], dp[v, n])
    dp = dp[:, 0]
    for v in range(1, N + 1):
        t = dp[v]
        c = C[t] if t != -1 else 0
        print(c)

signature = '(i8,i4[:],i4[:],i4[:],i4[:],i4[:])'
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main

N, M = map(int, readline().split())
G, ind = graph_input(N, M)
Q = int(readline())
nums = np.array(read().split(), np.int32)
V = nums[::3]
D = nums[1::3]
C = nums[2::3]

main(N, G, ind, V, D, C)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

string S;
int main(){

    cin >> S;
    int ans = 1 << 29;
    for(int j = 0; j < 2; j++){
        int tmp = 0;
        for(int i = 0; i < (int)S.size(); i++){
            if((S[i] == '0') ^ (i % 2 == j)){
                tmp++;
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
A, B, K = list(map(lambda x: int(x), input().split(" ")))
ans = []
for i in range(A, min([A + K, B + 1])):
  ans.append(i)
for j in range(max([B - K + 1, A]), B + 1):
  ans.append(j)

ans = list(set(ans))
ans.sort()

print("\n".join(list(map(lambda s: str(s), ans))))

Measured memory_bytes: 9068
#include <stdio.h>
int N,T;
int c[100],t[100];

int main(void)
{
	int i;
	int ans=1001;
	
	scanf("%d %d",&N,&T);
	
	for(i=0;i<N;i++){
		scanf("%d %d",&c[i],&t[i]);
	}
	
	for(i=0;i<N;i++){
		if(t[i]<=T){
			if(c[i]<ans){
				ans=c[i];
			}
		}
		//printf("%d\n",ans);
		//printf("%d\n",t[i]);
	}
	
	if(ans>1000){
		printf("TLE\n");
	}
	
	if(ans<=1000){
		printf("%d\n",ans);
		
	}
	
	return 0;
}

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

int main() {
    int n, d, a;
    cin >> n >> d;
    int i = 1;
    int ans = 0;
    int b =  2 * d + 1;
    a = 2 * d + 1;

    if(n <= a){
        cout << 1;
    }else {
        while (n > a) {
            a = b * i;
            i++;
            ans++;
        }

        cout << ans;
    }

}

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

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

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

    sort(a, a+n, greater<int>());
    int sumA = 0;
    int sumB = 0;
    for (int i=0; i<n; i++) {
        if (i%2 == 0) sumA += a[i];
        else sumB += a[i];
    }

    cout << sumA-sumB << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
#define s second
#define int long long
#define all(c) (c).begin(), (c).end()
// auto start = high_resolution_clock::now(); 
// auto stop = high_resolution_clock::now(); 
// auto duration = duration_cast<microseconds>(stop - start); 
 
// cout << duration.count() << endl; 
//  bool sortbysecdesc(const pair<ll,ll> &a, 
//                    const pair<ll,ll> &b) 
// { 
//        return a.second>b.second; 
// }
// ll binpow(ll a,ll b){
//  if(b == 0)return 1;
//  ll res = binpow(a,b/2);
//  res = (res*res)%mod;
//  if(b%2 != 0)res = (res*a)%mod;
//  return res;
// }
// int prime(ll n){
//  if( n== 1)return 0;
//  fo(i ,2, sqrt(n)+1){
//      if(n%i == 0)return 0;
//  }
//  return 1;
// }
 
int x,y;
 
void inverse(int a,int b){
    if(b == 0){
        x = 1;
        y = 0;
        return;
    }
    inverse(b,a%b);
    int cx = y;
    int cy =  x- (a/b)*y;
    x = cx;
    y = cy;
}
 
// 523857784
bool par(int a,int b){
    if(abs(a) > abs(b))return true;
    else if(abs(a) == abs(b)){
        if(a > b)return true;
        else return false;
    }
    else return false;
}
bool comp(int a,int b){
    if(abs(a) < abs(b))return true;
    else return false;
}
 
int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
     // int t;
     // cin >> t;
     // while(t--){


int m  = 1e5;
vi arr(m,0);
 fo(i,1,100){
    fo(j,1,100){
        fo(k,1,100){
            int v = (i+j+k);
            v = v*v;
            v -= (i*j+i*k+j*k);
            if(v < m)arr[v]++; 
        }
    }
 }
 int n;
 cin >> n;
 fo(i,1,n+1){
    cout << arr[i] << endl;
 }
 
return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
constexpr long long MAX = 1e15;

vector<long long> dijkstra(const vector<vector<pair<int, long long>>> &G, int s){
    struct RadixHeap {
        inline int bsr(long long x){ return (x == 0) ? -1 : 63-__builtin_clz(x); }
        vector<pair<long long, int>> v[65];
        long long last, sz;
        RadixHeap() : last(0), sz(0) { }
        inline bool empty () { return (sz == 0); }
        void push(long long x, int u) { sz++; v[bsr(x^last)+1].emplace_back(x, u); }
        pair<long long, int> pop () {
            if (!v[0].size()) {
                int i = 1;
                while (!v[i].size()) { i++; }
                last = min_element(v[i].begin(), v[i].end())->first;
                for (auto x : v[i]) { v[bsr(x.first^last)+1].emplace_back(x); }
                v[i].clear();
            }
            pair<long long, int> res = v[0].back();
            sz--;
            v[0].pop_back();
            return res;
        }
    };
    const long long inf = INT64_MAX;
    vector<long long> ret(G.size(), inf); ret[s] = 0;
    RadixHeap rh; rh.push(ret[s], s);
    while (!rh.empty()) {
        long long dist; int node;
        tie(dist, node) = rh.pop();
        if (ret[node] < dist) continue;
        for (auto &e : G[node]) {
            int next_node; long long next_dist;
            tie(next_node, next_dist) = e;
            if (ret[next_node] > ret[node] + next_dist){
                ret[next_node] = ret[node] + next_dist;
                rh.push(ret[next_node], next_node);
            }
        }
    }
    return ret;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<vector<pair<int, long long>>> g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        long long c1, c2;
        cin >> a >> b >> c1 >> c2;
        a--; b--;
        g1[a].emplace_back(b, c1);
        g1[b].emplace_back(a, c1);
        g2[a].emplace_back(b, c2);
        g2[b].emplace_back(a, c2);
    }
    
    vector<long long> d1 = dijkstra(g1, s); // yen
    vector<long long> d2 = dijkstra(g2, t); // snuuk
    vector<long long> d(n);
    for (int i = 0; i < n; i++) d[i] = d1[i] + d2[i];
    for (int i = n-1; i > 0; i--) d[i-1] = min(d[i-1], d[i]);
    
    for (auto& ans : d) cout << MAX - ans << '\n';
    return 0;
}

Measured memory_bytes: 19108
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    x = LI()
    l = I()
    k = int(math.log(n,2))
    f = [[i for j in range(k+1)] for i in range(n)]
    for i in range(n-1):
        j = bisect.bisect_left(x,x[i]+l)
        if j < n:
            if x[j] > x[i]+l:
                f[i][0] = j-1
            else:
                f[i][0] = j
        else:
            f[i][0] = j-1
    po2 = [1]*(k+1)
    for i in range(k):
        po2[i+1] = po2[i]*2
    for j in range(k):
        for i in range(n):
            f[i][j+1] = f[f[i][j]][j]
    q = I()
    for i in range(q):
        a,b = LI()
        a,b = [min(a,b)-1, max(a,b)-1]
        ans = 0
        while a < b:
            i = bisect.bisect_left(f[a],b)
            ans += po2[max(0,i-1)]
            a = f[a][max(0,i-1)]
        print(ans)

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 103320
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



int main() {
	ll a, b, x,ans;
	cin >> a >> b >> x;
	ll fa, fb;
	fa = ((a-1) / x)+1;
	fb = (b / x)+1;

	if (a == 0) {
		fa = 0;
	}

	ans = (fb - fa);
	cout << ans << endl;
	return 0;
}




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

using ll = long long;

int main() {
  int n,p; cin >> n >> p;
  int a,b;
 	a = b=0;
  ll dp[n+1][2];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < 2; j++)
      dp[i][j] = 0;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int c; cin >> c;
    for (int j = 0; j < 2; j++)
    	dp[i+1][j] += dp[i][j],
    	dp[i+1][j^(c&1)] += dp[i][j];
  }
  cout << dp[n][p] << endl;
  
  	
  	return 0;
}

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

int main(){
  int M,D,count=0;
  cin >> M >> D;
  for(int i=0;i<M;i++){
    for(int j=0;j<D;j++){
      int D1=(j+1)%10;
      int D10=(j+1)/10;
      if(D1>=2 && D10>=2 && D1*D10==i+1){
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N;
	cin >> N;
	vl A(N),S(N);
	FOR(i,0,N)cin >> A[i];
	FOR(i,0,N)S[i] = A[i];
	sort(ALL(S));
	map<ll,ll> m;
	FOR(i,0,N)m[S[i]] = i;
	ll ans = 0;
	FOR(i,0,N){
		if(i%2 != m[A[i]]%2)ans++;
	}
	cout << (ans+1)/2 << endl;
}

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

typedef long long ll;

int N;
ll A[52], B[52];

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

    ll sum = 0;
    for(int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        sum += A[i];
    }

    ll ans = 9e18;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            ll tsum = j;
            B[i] = j;
            for(int k = 0; k < N; k++) {
                if(i == k) continue;

                B[k] = (A[k] - A[i] + N + 1) % (N + 1);
                B[k] += j;
                B[k] %= (N + 1);
                if(B[k] == N) {
                    tsum = 9e18;
                    break;
                }
                tsum += B[k];
            }
            if(sum < tsum) continue;
            ll cnt = sum - tsum;

            bool ok = true;
            for(int k = 0; k < N; k++) {
                if((A[k] + cnt - B[k]) % (N + 1)) {
                    ok = false;
                    break;
                }
            }
            if(ok) ans = min(ans, cnt);
        }
    }

    printf("%lld", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{	
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	int n = s.size();
	vector<vector<int>> dp(n, vector<int>(2, INF));

	int x = s[0] - '0';
	dp[0][0] = x;
	dp[0][1] = 1 + 10 - x;

	for (int i = 1; i < n; i++) {
		x = s[i] - '0';
		// i-1桁において、繰り下げがなかった場合
		dp[i][0] = x + dp[i - 1][0];
		dp[i][1] = 1 + (10 - x) + dp[i - 1][0];

		// i-1桁において、繰り下げがあった場合
		if (x != 9) dp[i][0] = min(dp[i][0], dp[i - 1][1] + x);
		dp[i][1] = min(dp[i][1], dp[i - 1][1] + 9 - x);
	}
	cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    temp=0
    ans=0
    for i in range(N):
        a,b=MI()
        if a>temp:
            ans=a+b
            temp=a
            
    print(ans)

main()


Measured memory_bytes: 73780
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	vector<int> a(4);
	vector<int> b(2);

	for (int i = 0; i < 4; i++)
	{
		cin >> a.at(i);
	}

	for (int i = 0; i < 2; i++)
	{
		cin >> b.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

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

	cout << accumulate(a.begin(), a.begin() + 3, 0) + b.back() << endl;
}


Measured memory_bytes: 3140
using namespace std;
    #include <iostream>
    int main(){
      int N, a[10000], i, result;
      cin >> N;
      result = 0;
      for(i = 0; i < N; i++){
        cin >> a[i];
        while(a[i]%2 == 0){
          a[i] = a[i]/2;
          result++;
        }
      }
      cout << result << endl;
      return(0);
    }

Measured memory_bytes: 3628
S = input()
keta = len(S)
ans=0
for bit in range(1 << keta-1):
    f = S[0]

    for i in range(keta-1):
        if bit & (1<<i):
            f += "+"
        f += S[i+1]
    ans += sum(map(int,f.split("+")))
print(ans)

Measured memory_bytes: 3060
N ,Q = map(int, input().split())
S = input()
lr = [list(map(int,input().split())) for i in range(Q)]

c = [0]
n = 0

for i in range(1,len(S)):
    if S[i-1:i+1] == 'AC':
        n += 1
    c.append(n)

for x in lr:
    print(c[x[1]-1]-c[x[0]-1])

Measured memory_bytes: 30700
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
string str;

int main(){
	cin >> str;
	for(int i = 0; i < 3; i++){
		if(str[i] == '1'){cout << '9';}
		else{cout << '1';}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
P = 1000000000
for i in range(N):
    tmp = input().split(".")
    if len(tmp) == 2:
        a = int(tmp[1])
        for j in range(9-len(tmp[1])):
            a *= 10
        A.append(int(tmp[0]) * P + a)
    else:
        A.append(int(tmp[0]) * P)

div2 = [0 for i in range(N)]
div5 = [0 for i in range(N)]

for i in range(N):
    tmp = A[i]
    while tmp % 2 == 0:
        div2[i] += 1
        tmp = tmp//2
    while tmp % 5 == 0:
        div5[i] += 1
        tmp = tmp//5

cnt = [[0 for i in range(19)] for i in range(19)]

for i in range(N):
    d2 = div2[i]
    d5 = div5[i]
    if d2 > 18:
        d2 = 18
    if d5 > 18:
        d5 = 18
    cnt[d2][d5] += 1

ans = 0

for i in range(N):
    lower2 = 18 - div2[i]
    lower5 = 18 - div5[i]

    if lower2 < 0:
        lower2 = 0
    if lower5 < 0:
        lower5 = 0

    for j in range(lower2, 19):
        for k in range(lower5, 19):
            ans += cnt[j][k]

for a in A:
    if a % P == 0:
        ans -= 1

print(ans//2)


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

using namespace std;

typedef long long ll;

constexpr int MOD = 1000000007;
constexpr char nl = '\n';

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

  int N, K;
  cin >> N >> K;
  ll sum = 0;
  for (ll k = K; k <= N + 1; k++) {
    ll min_sum = (k - 1) * k / 2;
    ll max_sum = (N - (k - 1) + N) * k / 2;
    sum += max_sum - min_sum + 1;
    // cerr << max_sum << ":" << min_sum << nl;
  }
  cout << sum % MOD << nl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int t, n, sum;
vector<int> ans;
bool r = false;

void dfs(vector<int> v,int n, int d) {
    if (d == 0) {
        int s = 0;
        for (int i = 0; i < v.size(); i++) s += v[i];
        //for (int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << sum << " " << s << endl;
        if (s <= t && s > sum) {
            sum = s;
            ans = v;
            r = false;
        }
        else if (s <= t && s == sum) {
            r = true;
        }
        return;
    }
    
    while (1) {
        int a = n / d;
        int b = n % d;
        //printf("n=%d d=%d a=%d b=%d\n",n,d,a,b);
        vector<int> _v = v;
        _v.push_back(a);
        d /= 10;
        dfs(_v, b, d);
        if (d == 0) break;
    }
}

int main(void){
    while (cin>>t>>n && t && n) {
        sum = -1;;
        vector<int> a;
        int d = 1;
        while (n >= d*10) d *= 10; 
        dfs(a, n, d);
        
        if (r) cout << "rejected" << endl;
        else if (sum == -1) cout << "error" << endl;
        else {
            cout << sum;
            for (int i = 0; i < ans.size(); i++) cout << " " << ans[i];
            cout << endl;
        }
    }
}

Measured memory_bytes: 3000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void reverse_int(int* arr, int n)
{
    for (int i = 0; i < n / 2; i++) {
        int t = arr[i];
        arr[i] = arr[n - i - 1];
        arr[n - i - 1] = t;
    }
}

void reverse_char(char* arr, int n)
{
    for (int i = 0; i < n / 2; i++) {
        char t = arr[i];
        arr[i] = arr[n - i - 1];
        arr[n - i - 1] = t;
    }
}

int main(void)
{
    char s[100001];
    scanf("%s", s);

    int n = strlen(s);

    int* ans = calloc(n, sizeof(int));

    for (int times = 0; times < 2; times++) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'R') {
                cnt++;
            } else {
                ans[i] += cnt / 2;
                ans[i - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse_char(s, n);
        reverse_int(ans, n);

        for (int i = 0; i < n; i++) {
            s[i] = (s[i] == 'R' ? 'L' : 'R');
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%d%c", ans[i], (i == n - 1 ? '\n' : ' '));
    }
    return 0;
}


Measured memory_bytes: 896