akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

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

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N;
    cin >> N;
    vl A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));
    cout << A[N - 1] - A[0] << "\n";
}

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

using namespace std;

int main(){
    
    double a,b;
    while(cin >> a >> b)
    {
    	if(a<35.5 && b<71)cout<<"AAA"<<endl; 	
    	else if(a<37.5 && b<77)cout<<"AA"<<endl; 	
    	else if( a<40 && b<83 )cout<<"A"<<endl; 	
    	else if( a<43 && b<89 )cout<<"B"<<endl; 	
    	else if( a<50 && b<105 )cout<<"C"<<endl; 	
    	else if( a<55 && b<116 )cout<<"D"<<endl; 
    	else if( a<70 && b<148 )cout<<"E"<<endl; 		
    	else cout<<"NA"<<endl; 	
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
  int n;
  vector<int> data;
public:
  UnionFind(int _n):n(_n),data(_n,-1){}
  bool link(int a, int b){ //if new link, then true.
    int ra=find_root(a);
    int rb=find_root(b);
    if(ra!=rb){
      if(data[rb]<data[ra]) swap(ra,rb);
      data[ra]+=data[rb];
      data[rb]=ra;
    }
    return (ra!=rb);
  }
  bool check(int a, int b){ //if same set, then true.
    return (find_root(a)==find_root(b));
  }
  int find_root(int a){
    return ((data[a]<0)?a:(data[a]=find_root(data[a])));
  }
};

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

  UnionFind uf(N);
  rep(i,M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.link(a,b);
  }

  map<int,int> memo;
  rep(i,N){
    memo[uf.find_root(i)]++;
  }

  int mx = -1;
  FOR(it,memo){
    mx = max(mx, it->second);
  }

  cout << mx << endl;
  
  return 0;
}



Measured memory_bytes: 13464
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int,n+1,n+1)
	b := make([]int,n+1,n+1)
	c := make(map[int]int)

	for i := 1; i <= n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		a[i] = tmp
		b[i] = tmp + i
		_, ok := c[b[i]]
		if ok {
			c[b[i]]++
		} else {
			c[b[i]] = 1
		}
	}

	answer := 0
	for i := 1; i <= n; i++ {
		count, ok := c[-b[i] + 2 * i]
		if ok {
			answer += count
		}
	}

	fmt.Println(answer)
}

Measured memory_bytes: 20276
# Author: cr4zjh0bp
# Created: Tue Mar 24 00:01:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
a = na()

d = defaultdict(int)
for i in range(n):
    d[a[i] - 1] += 1
    d[a[i] + 1] += 1
    d[a[i]] += 1

print(max(d.values()))

Measured memory_bytes: 20108
import numpy as np
import math
n = int(input())
x = np.array(list(map(int, input().split())))

p0 = math.floor(x.sum()/n)
p1 = math.ceil(x.sum()/n)
cost0 = np.sum((x-p0)**2)
cost1 = np.sum((x-p1)**2)
print(min(cost0, cost1))


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

int main() {
  int N;
  cin >> N;
  ll sum=0;
  rep(i,N+1){
    if(i%3==0 || i%5==0) continue;
    else sum += i;
  }
  cout << sum << endl;
  return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((A==B&&A!=C) || (A==C&&A!=B) || (B==C&&B!=A)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using VS = vector<string>;

bool solve(int H, int W, VS &S){
	vi dy{-1,1,0,0}, dx{0,0,-1,1};//上下左右
	// bool ans = true;
	int y,x;
	rpz(h,H){
		rpz(w,W){
			if(S[h][w]=='.') continue;
			int d;
			for(d=0; d<4; ++d){
				y = h + dy[d];
				x = w + dx[d];
				if(y<0 || x<0 || y>H-1 || x>W-1) continue;
				if(S[y][x]!='.'){
					break;
				}
			}
			if(d>=4){
				// for(auto s:S) cout<<s<<"\n";///
				return false;
			}
		}
	}
	return true;
	// return ans;
}

int main(){
	int H,W; cin>>H>>W;
	VS S(H); rpz(i,H) cin>>S[i];
	ote(solve(H,W,S)?"Yes":"No");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

int main()
{
  double r ;
  std::cin >> r ;

  double n_pi = 3.141592653589 ;

  std::cout << std::fixed ;
  std::cout << std::setprecision( 5 ) << r * r * n_pi << " " << 2.0 * r * n_pi << std::endl ;

  return 0 ;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;

  if(N==2){
    cout << 1 << "\n";
    return;
  }

  i64 ans = 1;
  for(i64 i = 1; i * i <= N-1; i++){
    if((N-1)%i==0){
      if(i==1 or i*i==N-1) ans++;
      else ans += 2;
    }
  }

  for(i64 i = 2; i * i <= N; i++){
    if(N%i!=0) continue;
    i64 n = N;
    while(n%i==0) n /= i;
    if(n%i==1) ans++;
  }

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

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

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


int main() {
    int x,a,b;cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)){
      cout << 'A' << endl;
    }else{
      cout << 'B' << endl;
    }
    
  }       

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int Q = Integer.parseInt(tokens[2]);
		int[][] ranges = new int[N][N];
		for (int i = 0; i < M; ++i) {
			tokens = in.nextLine().split(" ");
			int l = Integer.parseInt(tokens[0]);
			int r = Integer.parseInt(tokens[1]);
			ranges[l - 1][r - 1]++;
		}
		int[][] sumRanges = new int[N][N + 1];
		for (int i = 0; i < N; ++i) {
			int sum = 0;
			for (int j = 1; j <= N; ++j) {
				sum += ranges[i][j-1];
				sumRanges[i][j] = sum;
			}
		}
		int[] p = new int[Q];
		int[] q = new int[Q];
		for (int i = 0; i < Q; ++i) {
			tokens = in.nextLine().split(" ");
			p[i] = Integer.parseInt(tokens[0]);
			q[i] = Integer.parseInt(tokens[1]);
		}
		for (int i = 0; i < Q; ++i) {
			int left = p[i];
			int right = q[i];
			System.out.println(calcSimple(left, right, sumRanges));
		}
		in.close();
	}

	private static int calcSimple(int p, int q, int[][] sumRanges) {
		int result = 0;
		for (int i = p - 1; i <= q - 1; ++i) {
			result += (sumRanges[i][q ] - sumRanges[i][p - 1]);
		}
		return result;
	}
}

Measured memory_bytes: 278940
n = int(input())
str_a = ''.join(['{:060b}'.format(a) for a in map(int, input().split())])
mod = 10**9 + 7

rest = 0
for d in range(60):
  ones = str_a[59-d::60].count('1')
  rest = (rest + 2**d * ones * (n - ones)) % mod
    
print(rest)


Measured memory_bytes: 65752
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ORDER 500000

struct NODE{
  int key,nil;
  struct NODE *left,*right,*parent;
};

typedef struct NODE Node;

Node *head;

void insert(Node*);
void print1(Node*);
void print2(Node*);

int main(){
  int i,num;
  Node *n;
  char order[ORDER][10];
  Node tmp;
  
  scanf("%d",&num);

  n = (Node *)malloc(sizeof(Node) * num);

  for(i=0; i<num; i++){
    scanf("%s",order[i]);
    if(strcmp(order[i],"print")!=0)scanf("%d",&n[i].key);
  }  
  
  for(i=0; i<num; i++){
    if(strcmp(order[i],"insert")==0) insert(&n[i]);
    if(strcmp(order[i],"print")==0){
      print1(head);
      printf("\n");
      print2(head);
      printf("\n");
    }
  }

  return 0;
}



void insert(Node *z){
  Node *y,*x;
  
  z->left = NULL;
  z->right = NULL;
  y = NULL;
  x = head;

  while(x != NULL){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;    
  }

  z->parent = y;
  
  if(y == NULL) head = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void print1(Node *node){
  if(node == NULL){
    return;
  }
  
  print1(node->left);
  printf(" %d",node->key);
  print1(node->right);
  return ;
}


void print2(Node *node){
  if(node == NULL){
    return;
  }
  
  printf(" %d",node->key);
  print2(node->left);
  print2(node->right);
  return;
}

Measured memory_bytes: 21116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
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(a>b){a=b;return 1;}return 0;}
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;cin >> n >> m;
	if(n >= 13){
		cerr << "test output" << endl;
		cout << m << endl;
	}else{
		if(n <= 5){
			cout << "0" << endl;
		}else{
		cout << m/2 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
    cin >> n;
  int a;
    cin >> a;
  if(n % 500 - a <= 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 171, task d, 2020/09/02
//ms,
/*
*/

int main(void){
  int N, Q;
  vector<int> a(100001);
  int64_t ans=0;

  cin >>N;
  for(int i=0;i<=100000;i++) a[i]=0;
  for(int i=0;i<N;i++){
    int tmp_a;
    cin>>tmp_a;
    a[tmp_a]++;
    ans+=tmp_a;
  }

  cin >>Q;
  for(int i=0;i<Q;i++){
    int b, c;
    cin >>b >>c;

    ans += (c-b)*a[b];
    cout <<ans<<endl;

    a[c] += a[b];
    a[b] = 0;
  }


  return 0;
}
/*
愚直にやると、10^5個の成分に行う処理を10^5回やるため、10^10回の操作。
これは無理。
mapでとっておけば検索がlogNオーダーになるから全体NlogN+Qでよくない？
→いいっちゃいいんだけど、線形オーダーの解がある。お前はmapが好きすぎ。

前回もmap使ったしね。今回は模範解答のやつを実装しよう。
mapのkeyにしてた分をvectorの添え字で管理する。
*/


Measured memory_bytes: 3736
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] p = new int[101];
		int[] s = new int[31];
		while(sc.hasNext()) {
			String[] t = sc.next().split(",");
			if(t[0].equals("0")) break;
			p[Integer.parseInt(t[0])] = Integer.parseInt(t[1]);
			s[Integer.parseInt(t[1])]++;
		}
		int[] r = new int[31];
		int k = 1;
		for(int i = 30; i >= 0; i--) {
			r[i] = k;
			if(s[i] != 0) {
				k++;
			}
		}
//		for(int i = 30; i >= 0; i--) {
//			System.out.printf("%d %d\n", i, r[i]);
//		}
//		for(int i = 1; i <= 5; i++) {
//			System.out.println(r[p[i]]);
//		}
		while(sc.hasNext()) {
			int q = sc.nextInt();
			System.out.println(r[p[q]]);
		}
		sc.close();
	}
}


Measured memory_bytes: 26068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int S;
  cin >> S;
  int s1 = S / 100;
  int s2 = (S - s1 * 100) / 10;
  int s3 = S - (s1 * 100 + s2 * 10);
  cout << s1 + s2 + s3 <<endl;
}

Measured memory_bytes: 256
import math
n=int(input())
a=(list(map(int,input().split())))
a.append(0)
al=0
bo=0
for i in range(0,(n+1)//2,1):
    al+=max(a)
    a.remove(max(a))
    
    bo+=max(a)
    a.remove(max(a))
print(al-bo)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


// 素因数が何乗かをmapで返却する
map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


void solve() {
    ll N, M; cin >> N >> M;
    auto pf = prime_factor(M);

    ll res = 1;
    for(auto a: pf){
        res = modint(modint(res) * comb(a.second + N - 1, a.second));
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

#define ff first
#define ss second
#define mp make_pair
#define sz size()
#define pb push_back
using ll = long long;
using pii = pair<int, int>;

std::vector<pii> v;

int main() {

  int a, b, c, x, y, d;

  cin >> x >> y >> a >> b >> c;

  for(int i = 0; i < a; i++){
    cin >> d;
    v.pb({d, 0});
  }

  for(int i = 0; i < b; i++){
    cin >> d;
    v.pb({d, 1});
  }

  for(int i = 0; i < c; i++){
    cin >> d;
    v.pb({d, 2});
  }

  sort(v.begin(), v.end(), greater< pii>());

  int rr = 0, bb = 0;
  for(int i = 0 ; i < x + y; i++){
    if(v[i].ss == 0)rr++;
    if(v[i].ss == 1)bb++;
  }
  ll ans = 0LL;
  int n = v.size();
  
  if(rr > x){
    for(int i = 0; i < n; i++){
      if(!x && !y)break;
      if(v[i].ss == 0){
        if(x){
          x--;
          ans += v[i].ff;
        }
      }
      else if(v[i].ss == 1 || v[i].ss == 2){
        y--;
        ans += v[i].ff;
      }
    }
  }
  else if(bb > y){
    for(int i = 0; i < n; i++){
      if(!x && !y)break;
      if(v[i].ss == 1){
        if(y){
          y--;
          ans += v[i].ff;
        }
      }
      else if(v[i].ss == 0 || v[i].ss == 2){
        x--;
        ans += v[i].ff;
      }
    }
  }
  else {
    for(int i = 0; i < x + y; i++)ans += v[i].ff;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  int a = 0, b = 0;
  while (n--) {
    string l, r;
    cin >> l >> r;
    if (l == r) a++, b++;
    if (l > r) a += 3;
    if (l < r) b += 3;
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}

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

int main() {
  int k, n;
  int a[1000000 + 2];
  cin >> k >> n;
  for (int i = 0; i < n; i++) cin >> a[i];

  int ans = 1000000;
  for (int i = 0; i < n; i++) {
    int l, r;

    if (i == 0) {
      r = a[n-1] - a[0];
    } else {
      r = k - (a[i] - a[i - 1]);
    }
    ans = min(ans, r);

    if (i == n-1) {
      l = a[n-1] - a[0];
    } else {
      l = k - (a[i + 1] - a[i]);
    }
    ans = min(ans, l);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 

int32_t main()
{
    fast;
    int n;cin>>n;
    double den=0;
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        den+=(1.0/x);
    }
    double ans=1/den;
    cout<<PSET(ans,6);
}

Measured memory_bytes: 256
s = input()
n = len(s)
mod = n % 3
counts=[s.count('a'),s.count('b'),s.count('c')]
results=[n//3]*3
for i in range(mod):
  results[i] += 1
counts.sort()
results.sort()
for j in range(3):
  if counts[j] != results[j]:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (run(sc)) {}
  }

  static boolean run(Scanner sc) {
    int n = sc.nextInt();
    if (n == 0) {
      return false;
    }
    String k = "";
    for (int i = 0; i < n + 1; i++) {
      int m = sc.nextInt();
      int[] x = new int [m];
      int[] y = new int [m];
      for (int j = 0; j < m; j++) {
        x[j] = sc.nextInt();
        y[j] = sc.nextInt();
      }
      String id = normalize2(x, y);
      // System.out.println(i + " : " + id);
      if (i == 0) {
        k = id;
      } else {
        if (k.equals(id)) {
          System.out.println(i);
        }
      }
    }
    System.out.println("+++++");
    return true;
  }

  static String normalize2(int x[], int y[]) {
    int l = x.length;
    int[] ids1 = normalize(x, y);
    int[] ids2 = new int[ids1.length];
    for (int i = 0; i < ids1.length; i++) {
      ids2[i] = ids1[ids1.length - i - 1];
    }
    for (int i = 1; i < ids2.length; i += 2) {
      ids2[i] = ~ids2[i] + 2;
    }
    String id1 = "";
    String id2 = "";
    for (int i = 0; i < ids1.length; i += 2) {
      id1 += ids1[i];
      id2 += ids2[i];
      if (i + 1 < ids1.length) {
        id1 += "rl".charAt(ids1[i + 1]);
        id2 += "rl".charAt(ids2[i + 1]);
      }
    }
    return id1.compareTo(id2) > 0 ? id1 + id2 : id2 + id1;
  }

  static int[] normalize(int x[], int y[]) {
    int d = dir(x[0], y[0], x[1], y[1]);
    int l = Math.abs(x[0] - x[1]) + Math.abs(y[0] - y[1]);
    int[] ids = new int[(x.length - 1) * 2 - 1];
    ids[0] = l;
    for (int i = 1; i + 1 < x.length; i++) {
      int[] dx = dirx(x[i], y[i], x[i + 1], y[i + 1], d);
      int d2 = dx[0];
      d = dx[1];
      int l2 = Math.abs(x[i] - x[i + 1]) + Math.abs(y[i] - y[i + 1]);
      ids[i * 2 - 1] = d2;
      ids[i * 2] = l2;
    }
    return ids;
  }

  static int D1 = 0;
  static int D2 = 1;
  static int D3 = 2;
  static int D4 = 3;

  static int[] dirx(int x1, int y1, int x2, int y2, int d) {
    if (d == D1) {
      return x1 < x2 ? new int[]{ 0, D2 } : new int[]{ 1, D4 };
    } else if (d == D3) {
      return x1 < x2 ? new int[]{ 1, D2 } : new int[]{ 0, D4 };
    } else if (d == D2) {
      return y1 < y2 ? new int[]{ 1, D1 } : new int[]{ 0, D3 };
    } else {
      return y1 < y2 ? new int[]{ 0, D1 } : new int[]{ 1, D3 };
    }
  }

  static int dir(int x1, int y1, int x2, int y2) {
    if (x1 == x2) {
      return y1 < y2 ? D1 : D3;
    }
    return x1 < x2 ? D2 : D4;
  }
}

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

int main() {
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	char t=s[0];
	if(s.size()%2){
		cout<<"No";
		return 0;
	}
	
	for(int i=0;i<s.size();i++){
		if(s[i]!=t){
			
			if(i%2==0) t=s[i];
			
			else {
				
				cout<<"No";
				return 0;
			}
		}
		
	}
	cout<<"Yes";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  char a, b;
  cin >> a >> b;
  int na = a-'0';
  int nb = b-'0';
  string sa = "";
  string sb = "";
  rep(i,nb) {
    sa += a;
  }
  rep(i,na) {
    sb += b;
  }
  cout << (sa < sb ? sa : sb) << endl;
  return 0;
}

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

int main(){
	int n,m,k,a,ans=0;
	cin>>n>>m;
	int b[m+1]={};
	for(int i=0;i<n;i++){
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>a;
			b[a]++;
		}
	}
	for(int i=1;i<=m;i++){
		if(b[i]==n) ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

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

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

  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = 0;
  if (a > b) swap(a, b);
  vector<vector<ll>> f(n + 1, vector<ll>(2, 0));
  if (b >= 2) {
    f[0][0] = 1;
    f[0][1] = 1;
    FOR(i, 1, n + 1) {
      rep(k, 2) {
        FOR(j, 1, i + 1) {
          if (k == 0 && j < a) continue;
          f[i][k] = (f[i][k] + f[i - j][k ^ 1]) % mod;
        }
      }
    }
    vector<ll> g(n + 1);
    g[0] = 1;
    FOR(i, 1, n + 1) g[i] = (f[i][0] + f[i][1]) % mod;
    //rep(i, n + 1) cout << g[i]<< '\n';
    vector<vector<ll>> dp(n, vector<ll>(2, 0));
    FOR(i, 1, n) {
      if (i < a) dp[i][0] = (dp[i][0] + 1) % mod;
      FOR(j, 1, min(i, a)) dp[i][0] = (dp[i][0] + dp[i - j][1]) % mod;
      if (i < b) dp[i][1] = (dp[i][1] + g[i - 1]) % mod;
      FOR(j, 1, min(i, b)) dp[i][1] = (dp[i][1] + dp[i - j][0] * g[max(0LL, j - 2)]) % mod;
      if (n - i < b) ans = (ans + dp[i][0] * g[n - i - 1]) % mod;
      if (n - i < a) ans = (ans + dp[i][1]) % mod;
    }
  }
  ans = (modpow(2, n) - ans + mod) % mod;
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;
import java.util.Arrays;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int number[] = new int[3];
 
        for (int i=0;i<3;i++){
            number[i]=sc.nextInt();
        }
 
        Arrays.sort(number);
 
        System.out.print(number[0] +" ");
        System.out.print(number[1] +" ");
        System.out.println(number[2]);
    }
}


Measured memory_bytes: 26212
// AOJ 1030 Cubes Without Holes
// 2018.2.3 bal4u@uu

#include <stdio.h>

#include <stdio.h>
#include <string.h>
 
char buf[15], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int cno;
char f[134217728];
int ans;
 
void cnt(int x) { if (f[x] != cno) f[x] = cno, ans++; }
 
int main()
{
	int n, h, a, b, x, y, z, t;
	char *c;

	while (fgets(p=buf, 15, stdin) && *p != '0') {
		cno++;
		n = in(), h = in();

		ans = 0;
		while (h--) {
			fgets(p=buf, 15, stdin);
			c = p, p += 3, a = in()-1, b = in()-1;
			if (*c == 'x' && *(c+1) == 'y') {
				t = (a << 18) | (b << 9);
				for (z = 0; z < n; z++) cnt(t | z);
			} else if (*c == 'x' && *(c+1) == 'z') {
				t = (a << 18) | b;
				for (y = 0; y < n; y++) cnt(t | (y << 9));
			} else {
				t = (a << 9) | b;
				for (x = 0; x < n; x++) cnt(t | (x << 18));
			}
		}
		printf("%d\n", n*n*n - ans);
	}
	return 0;
}


Measured memory_bytes: 126040
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(), v.end());
    vector<int> v2;
    v2.reserve(m - 1);
    for (int i = 0; i < m-1; ++i) {
        v2.emplace_back(v[i+1]-v[i]);
    }
    sort(v2.begin(), v2.end());
    int ans = 0;
    for (int i = 0; i < m-n; ++i) {
        ans += v2[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

void solve() {
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++) {
        if(i%3!=0 && i%5!=0) ans += i;
    }
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

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

    if (n <= k) {
        cout << 1 << endl;
        ret();
    }

    n--;
    k--;

    cout << (n + k - 1) / k << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]
# S_ij = S[i-1][j-1]
S_count = []
for i in range(H):
    Count = []
    for j in range(W):
        if S[i][j] == ".":
            count = 0
            for t in range(8):
                if j+dx[t] <0 or j+dx[t] > W-1 or i+dy[t] <0 or i+dy[t] >H-1:
                    pass
                elif S[i+dy[t]][j+dx[t]] == "#":
                    count += 1
                else:
                    pass
        else:
            count = "#"
        Count.append(count)
    S_count.append(Count)
for i in range(H):
    R = "".join(map(str,S_count[i]))
    print(R)

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

int main(void)
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  int k;
  string s;
  cin >> k >> s;
  string ans;
  if (s.size() <= k) {
    ans = s;
  } else {
    ans = s.substr(0, k) + "...";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  string s;
  cin >> s;

  if(s[2]==s[3]&&s[4]==s[5]) {
    yes();
  }else {
    no();
  }

  return 0;
}


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

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

  sort(A.begin(), A.end());
  A[n-1] /= 2;
  int sum = 0;
  rep(i, n) sum += A[i];
  cout << sum << endl;
}


Measured memory_bytes: 256
a, b, c, x, y = gets.chop.split.map(&:to_i)

min = x * a + y * b
if x > y
  temp = 2 * c * y + (x - y) * a
  min = temp if min > temp
  temp = 2 * c * x
  min = temp if min > temp
else
  temp = 2 * c * x + (y - x) * b
  min = temp if min > temp
  temp = 2 * c * y
  min = temp if min > temp
end
puts min


Measured memory_bytes: 1916
#include <stdio.h>

int main(void){
  
  int n, i, count = 0;
  
  scanf("%d", &n);
  
  
  for(i = 1; i <= n; i++){
    if(!(10 <=i && i <= 99 || 1000 <= i && i <= 9999 || 100000 <= i))
      count++;
  }
  
  
  printf("%d", count);
 return 0; 
}

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

void swap(int A[],int a,int b){
	int tmp=A[a];
	A[a]=A[b];
	A[b]=tmp;
}

int partition(int a[],int p,int r){
	int x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			swap(a,i,j);
		}
	}
	swap(a,i+1,r);
	return i+1;
}

int main(){
	int n, a[100000];
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	int idx = partition(a,0,n-1);
	for(int i=0;i<n;i++){
		if(i==idx){
			cout << "[";
		}
		cout << a[i];
		if(i==idx){
			cout << "]";
		}
		if(i != n-1){
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}



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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        char[][] a = new char[n][n];
        char[][] b = new char[m][m];
        for (int i = 0; i < n; i++) {
            a[i] = in.ns().toCharArray();
        }
        for (int i = 0; i < m; i++) {
            b[i] = in.ns().toCharArray();
        }
        boolean flag = true;
        out:for (int i = 0; i < n - m + 1; i++) {
            in:for (int j = 0; j < n - m + 1; j++) {
                flag = true;
                for (int k = 0; k < m; k++) {
                    for (int l = 0; l < m; l++) {
                        if(a[i+k][j+l]!=b[k][l]){
                            flag = false;
                            continue in;
                        }
                    }
                }
                if(flag) break out;
            }
        }
        out.println(flag?"Yes":"No");
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 23252
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL n;
    cin >> n;
    VL sieve(1e6 + 1, 0);
    for (int i = 2; i <= 1e6; i++) {
        if (sieve[i] != 0) {
            continue;
        }
        for (int j = i; j <= 1e6; j += i) {
            sieve[j] = i;
        }
    }

    VL a(n);
    set<LL> primesSeen;
    LL gcdVal;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0) {
            gcdVal = a[0];
        } else {
            gcdVal = std::gcd(gcdVal, a[i]);
        }

        if (a[i] == 1) {
            continue;
        }
        set<LL> newPrimes;
        while (flag && a[i] > 1) {
            if (primesSeen.count(sieve[a[i]])) {
                flag = false;
                break;
            } else {
                newPrimes.insert(sieve[a[i]]);
                a[i] /= sieve[a[i]];
            }
        }

        primesSeen.insert(newPrimes.begin(), newPrimes.end());
    }

    if (flag) {
        cout << "pairwise coprime" << endl;
    } else if (gcdVal == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
    return 0;
}

Measured memory_bytes: 18340
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a*b%2==0)
        cout<<"Even"<<endl;
    else
        cout<<"Odd"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 500 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

long long k, A, B;

int main() {
    cin >> k >> A >> B;
    long long ans = k + 1;
    if(k >= A - 1) {
        long long tmp = A + (k - A + 1)/2*(B - A) + (k - A + 1)%2;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    long long Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    
	long long min,off,sum,prise,total;
    vector <long long>v={Q*4,H*2,S*1,D/2};
	vector <long long>t={Q,H,S,D};
	vector <double>m={0.25,0.5,1.0,2.0};
	off=0;
	sum=0;
	int end=4;
	while(N!=0){
		min=v[0];
		if(m[off]==2.0)end=3;
		off=0;
		for(int i=1 ; i<end ; i++){
			if(min>v[i] && m[i]<=N){
				min=v[i];
				off=i;
			}
		}
		prise=(long long)N/m[off];
		total=(long long)(prise*t[off]);
		sum+=total;
		N-=(long long)(m[off]*prise);
	}
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char str[6];
  scanf("%s",&str);
  //printf("%s",str);
  if(str[0]=='S'){
    printf("Cloudy");
  }
  if(str[0]=='C'){
    printf("Rainy");
  }
  if(str[0]=='R'){
    printf("Sunny");
  }
}

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

using namespace std;
using i64 = int64_t;
i64 MOD = 1e9 + 7;

i64 solve(){
    
    string n;
    cin >> n;
    int cnt = 0;
    if(n == "0000")
        return MOD;
    if(n[0] == n[1] && n[0] == n[2] && n[0] == n[3]){
        cout << "NA" << endl;
        return 1;
    }
    for(; n != "6174"; ++cnt){
        auto f = [&]{
            i64 v = 0;
            int b = 1000;
            for(int i = 0; i < 4; ++i){
                v += (n[i] - '0') * b;
                b /= 10;
            }
            return v;
        };
        auto g = [&](i64 t){
            string s = "0000";
            int b = 1000;
            for(int i = 0; i < 4; ++i){
                s[i] += (t / b) % 10;
                b /= 10;
            }
            return s;
        };
        sort(n.begin(), n.end());
        i64 t1 = f();
        reverse(n.begin(), n.end());
        i64 t2 = f();
        n = g(t2 - t1);
    }
    cout << cnt << endl;
    
    return true;
}

signed main(){
    while(solve() != MOD);
}


Measured memory_bytes: 3140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();

        Dice dice = new Dice(a, b, c, d, e, f);

        String cmd = sc.next();

        for (int i = 0; i < cmd.length(); i++) {
            switch (cmd.charAt(i)) {
            case 'N': dice = dice.rollToN(); break;
            case 'S': dice = dice.rollToS(); break;
            case 'W': dice = dice.rollToW(); break;
            case 'E': dice = dice.rollToE(); break;
            }
        }

        System.out.println(dice.getTop());
    }

    private static class Dice {
        private int t;
        private int s;
        private int e;
        private int w;
        private int n;
        private int b;

        public Dice(int t, int s, int e, int w, int n, int b) {
            this.t = t;
            this.s = s;
            this.e = e;
            this.w = w;
            this.n = n;
            this.b = b;
        }
        public Dice rollToN() {
            return new Dice(s, b, e, w, t, n);
        }
        public Dice rollToS() {
            return new Dice(n, t, e, w, b, s);
        }
        public Dice rollToW() {
            return new Dice(e, s, b, t, n, w);
        }
        public Dice rollToE() {
            return new Dice(w, s, t, b, n, e);
        }
        public int getTop() {
            return t;
        }
    }
}



Measured memory_bytes: 26272