akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int N, d;
	cin >> N;
	int total = 0;
	vector<int> happy(N);
	for (int i = 0; i < N; i++) {
		cin >> d;
		happy.at(i) = d;
	}
	for (int j = 0; j < N - 1; j++) {
		for (int k = 1 + j; k < N; k++) {
			total += happy.at(j) * happy.at(k);
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3612
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <limits>
#include <numeric>
#include <iterator>

using namespace std;

class Card{
public:// variables
  char mark;
  int  num;

public:// constructors
  Card(char mark, int num){
    this->mark = mark;
    this->num  = num;
  }
  
public:// methods
  int comp(const Card & that) const
  { // this - that 
    return this->num - that.num;
  }

  inline bool operator>(const Card & that)  const{return (this->comp(that)>0);}
  inline bool operator>=(const Card & that) const{return (this->comp(that)>=0);}
  inline bool operator<(const Card & that)  const{return (this->comp(that)<0);}
  inline bool operator<=(const Card & that) const{return (this->comp(that)<=0);}

  inline bool operator==(const Card & that) const{
    // cout << "comp" << endl;
    // cout << "this: " << this->mark << ' ' << this->num << endl;
    // cout << "that: " << that.mark << ' ' << that.num << endl;
    return (this->mark==that.mark && this->num==that.num);}

  friend ostream& operator<<(ostream& os, const Card & c);
};

ostream& operator<<(ostream& os, const Card & c){
  os << c.mark << ' ' << c.num;
  return os;
}

int partition_tail_pivot(vector<Card>& a, int p, int r){
  auto piv = a[r];
  int i = p-1;
  for(int j = p; j < r; ++j){
    if(a[j] <= piv){
      ++i;
      swap(a[i], a[j]);
    }
  }
  swap(a[i+1], a[r]);
  return i+1;
}

void q_sort(vector<Card>& a, int p, int r){
  int q = partition_tail_pivot(a, p, r);
  if(p < q-1) q_sort(a, p, q-1);
  if(q+1 < r) q_sort(a, q+1, r);
}


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

  int n;
  vector<Card> a; // 1 .. 10000
  cin >> n;
  for(int i = 0; i<n; ++i){
    //Card a_i;
    char mark_i;
    int num_i;
    cin >> mark_i;
    cin >> num_i;
    Card a_i (mark_i, num_i);
    a.push_back(a_i);
  }

  auto b = a;
  stable_sort(b.begin(), b.end());
  q_sort(a, 0, n-1);
  // for(auto b_i : b){
  //   cout << b_i << endl;
  // }
  // cout << "----" << endl;
  cout << (b==a?"Stable":"Not stable")
       << endl;
  // cout << (b[0]==a[0]?"OK":"NG")
  //      << endl;
  for(auto a_i : a){
    cout << a_i << endl;
  }

  return 0;
}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
 
int N;
int A[16];
int x[16][16];
int y[16][16];
 
int main(void){
  int bit = 0;
  int max = 0;
  bool check;
  cin >> N;
  
  for(int i = 1; i <= N; i++){
    cin >> A[i];
    for(int j = 1; j <= A[i]; j++){
      cin >> x[i][j] >> y[i][j];
    }
  }
  
  for(bit = 1; bit <= (1<<N); bit++){
    check = true;
    for(int i = 1; i <= N; i++){
      if(!(1 & (bit>>(i-1)))) continue;
      for(int j = 1; j <= A[i]; j++){
        if((bit >> (x[i][j]-1) & 1) ^ y[i][j]) check = false;
      }
    }
    
    int count = 0;
    if(check){   
      for(int i = 1; i <= N; i++){
        if(1 & (bit >> (i - 1))) count++;
      }
    }
    if(count > max) max = count;
  }
  
  cout << max << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    return 0;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))
Ad, ans = {}, sum(A)
for a in A:
    Ad[a] = Ad.get(a, 0) + 1

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    Ad[C] = Ad.get(C, 0) + Ad.get(B, 0)
    ans += (C - B) * Ad.get(B, 0)
    Ad[B] = 0
    print(ans)


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
#define rev(v) reverse(v.begin(), v.end());

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n, m, sum;
    sum = 0;
    cin >> n >> m;
    vector<int> a(m);
    REP(i,0,m) cin >> a[i];

    REP(i,0,m) sum+=a[i];
    if((n-sum)<0) cout << -1;
    else cout << (n-sum);
    cout << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行目個数、2行目の複数の数字を配列に格納
		//   3
		//   1 2 3
		int N = Integer.parseInt(br.readLine());
		String[] ss0 = br.readLine().trim().split(" ", 0);
		Integer[] ii0 = new Integer[N];
		for(int i = 0; i < N; i++){
			ii0[i] = Integer.parseInt(ss0[i]);
		}
		
		Integer[] ii1 = new Integer[N];
		int a = 0;
		for(int i = 0; i < N; i++){
			a = a + (ii0[i] % 2);
		}
		
		if ((a % 2) == 1) {
	        System.out.println("NO");
	    } else {
	        System.out.println("YES");
	    }


        //System.out.println(ans);
        return;
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}

Measured memory_bytes: 33952
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    long double t, x;
    cin >> t >> x;

    cout << fixed << setprecision(10) << t / x << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int a, b, k;
	bool sw = true;
	cin >> a >> b >> k;
	rep(i, k) {
		int t;
		if (sw) {
			t = a / 2;
			a /= 2;
			b += t;
		}
		else {
			t = b / 2;
			b /= 2;
			a += t;
		}
		sw = !sw;
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char weather[7];

    scanf("%s",weather);

    if( weather[0] == 'S' ){
        printf("Cloudy\n");
    } else if ( weather[0] == 'C' ){
        printf("Rainy\n");
    } else if ( weather[0] == 'R' ){
        printf("Sunny\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int sum;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while(a--)
    {
        if(cnt==k)
        {
            cout<<sum<<endl;
            return 0;
        }
        cnt++;
        sum++;
    }
    while(b--)
    {
        if(cnt==k)
        {
            cout<<sum<<endl;
            return 0;
        }
        cnt++;
    }
    while(c--)
    {
                if(cnt==k)
        {
            cout<<sum<<endl;
            return 0;
        }
        cnt++;
        sum--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3628
/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
 */

#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <sstream>

struct Coodinate {
  double x;
  double y;
};

void printCoodinate(const Coodinate &xy) {
  std::ostringstream oss;
  oss << std::fixed << std::setprecision(8);
  oss << xy.x << " " << xy.y;
  std::cout << oss.str() << std::endl;
}

void kochCurve(Coodinate &p1, Coodinate &p2,
               unsigned short n) {
  if (n == 0) {
    return;
  }
  const double Pi = atan((double)INFINITY) * 2;
  const double COS60 = cos(Pi * 60 / 180);
  const double SIN60 = sin(Pi * 60 / 180);
  Coodinate s = {(2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3};
  Coodinate t = {(p1.x + 2 * p2.x) / 3, (p1.y + 2 * p2.y) / 3};
  Coodinate u = {(t.x - s.x) * COS60 - (t.y - s.y) * SIN60 + s.x,
                           (t.x - s.x) * SIN60 + (t.y - s.y) * COS60 +
                               s.y};
  kochCurve(p1, s, n - 1);
  printCoodinate(s);
  kochCurve(s, u, n - 1);
  printCoodinate(u);
  kochCurve(u, t, n - 1);
  printCoodinate(t);
  kochCurve(t, p2, n - 1);
}

int main(int argc, char const *argv[]) {
  unsigned short n;
  std::string Param;
  std::istringstream Stream;
  getline(std::cin, Param);
  Stream.str(Param);
  Stream >> n;
  Stream.clear();
  Coodinate p1 = {0, 0};
  Coodinate p2 = {100, 0};
  printCoodinate(p1);
  kochCurve(p1, p2, n);
  printCoodinate(p2);

  return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin >>n;
    vector<int>a(n);
    
    rep(i,n)cin>>a[i];
    sort(all(a));

    if(a[0]*2 < a[1])ans=1;
    else ans=2;

    sum=a[0]+a[1];
    rep1(i,2,n){
        if(a[i] > 2*sum)ans=0;
        sum += a[i];
        ans++;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=100000 +117;
const int MM=100000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int deg[NN]={};
vector<int> p[NN];
int l;
int r;
int acnt=0;
int a[NN]={};
void dfs(int x,int fa){
	int xt=0;
	int cnt=0;
	for(int i=0;i<p[x].size();++i){
		int cur=p[x][i];
		if(deg[cur]!=1){
			if(cur!=fa)xt=cur;
		}
		else ++cnt;
	}
	a[++acnt]=cnt;
	if(xt)dfs(xt,x);
}
int res[2][NN]={};
void getres(int k){
	int cc=0;
	int now=0;
	res[k][++now]=++cc;
	for(int i=1;i<=acnt;++i){
		int s=a[i];
		for(int j=1;j<=s;++j){
			res[k][++now]=cc+1+j;
		}
		res[k][++now]=cc+1;
		cc+=s+1;
	}
	res[k][++now]=++cc;
}
bool cmp(){
	int pos=1;
	while(pos<=n&&res[0][pos]==res[1][pos])++pos;
	return res[1][pos]<res[0][pos];
}
int main(){
	//open();
	n=read();
	if(n==2){
		printf("1 2\n");
		return 0;
	}
	for(int i=1;i<n;++i){
		int x=read(),y=read();
		deg[x]++,deg[y]++;
		p[x].push_back(y);
		p[y].push_back(x);
	}
	int duan;
	bool fl=1;
	for(int i=1;i<=n;++i){
		int cnt=0;
		for(int j=0;j<p[i].size();++j){
			int cur=p[i][j];
			if(deg[cur]!=1)++cnt;
		}
		if(cnt<=1&&deg[i]!=1)duan=i;
		if(cnt>2)fl=0;
	}
	if(!fl){
		printf("-1\n");
		return 0;
	}
	dfs(duan,0);
	a[1]--;
	a[acnt]--;
	getres(1);
	for(int i=1;i<=acnt/2;++i)swap(a[i],a[acnt+1-i]);
	getres(0);
	int k=cmp();
	for(int i=1;i<=n;++i){
		printf("%d ",res[k][i]);
	}
	putchar('\n');
	close();
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>


using namespace std;


int N;


int main()
{


	cin >> N;
	int ans = 0;

	auto C = vector<vector<int>>(10, vector<int>(10, 0));
	int r = 1;
	for (int i = 1; i <= N; i++) {
		if (i == r*10) {
			r *= 10;
		}

		C[i / r][i % 10]++;
	}



	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += C[i][j] * C[j][i];
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int N = 3010;
double dp[N][N] = {0}, p[N];
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for (int i = 2; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int h = 1; h <= i; h++) {
            dp[i][h] = dp[i - 1][h - 1] * p[i]
                     + dp[i - 1][h] * (1 - p[i]);
        }
    }
    double ans = 0;
    for (int h = (n + 1) / 2; h <= n; h++) {
        ans += dp[n][h];
    }
    cout << setprecision(9) << fixed << ans << "\n";
}

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

#define NL '\n'
#define eps 1e-9
#define ins insert
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x) ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define rep(ii,aa,bb) for(int (ii)=int(aa);(ii)<(int)(bb);++(ii))
#define per(ii,aa,bb) for(int (ii)=int(aa)-1;(ii)>=(int)(bb);--(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))



int main(){
  _fastIO();
  ll a;
  cin  >> a;
  cout << (a / 2) * (a - (a/2)) ;
}

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

name = []
score = []
for i in range(n):
    a, b = input().split()
    b = int(b)
    name.append(a)
    score.append(b)
rank = []

N = sorted(list(set(name)))
A = []
B = []
t = 1
for i in N:
    A = []
    B = []
    for j in range(n):
        if name[j] == i:
            A.append(j)
            B.append(score[j])

    C = zip(B, A)
    C = list(reversed(sorted(C)))
    D, E = zip(*C)

    for i in E:
        print(i+1)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = (char)(S[K - 1] - 'A' + 'a');
    cout << S << endl;
}


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

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

typedef long long ll;
typedef pair<int, int> P;
int mod = 1000000007;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int H[N]; rep(i, N) cin >> H[i];
    rep(i, N-1){
        if(i == 0){
            H[i]--;
        }
        else{
            if(H[i-1] < H[i]) H[i]--;
        }
        if(H[i] > H[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int x; cin >> x;
  
  int sum = 0;
  int ans;
  
  for (int i = 1; i < (1<<30); i++) {
    sum += i;
    if (sum >= x) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  cin >> n;
  vl a(n);
  ll sum = 0;
  rep (i, n) {
    cin >> a[i];
    sum += a[i];
  }

  ll now = 0;
  ll ans = INF;
  rep (i, n - 1) {
    now += a[i];
    chmin(ans, abs((sum - now) - now));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc166/tasks/abc166_d

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

ll pow5(ll x)
{
    auto t = x * x;
    return t * t * x;
}

map<ll, ll> d;

int main(int, const char**)
{
    ll x;
    cin >> x;
    ll prev = 0;
    ll i = 0;
    while(true)
    {
        auto x = pow5(i);
        d[x] = i;
//        cout << x - prev << endl;
        if(x - prev > 1000000000)
        {
            break;
        }
        i++;
        prev = x;
        d[pow5(-i)] = -i;
    }

    ll a = 0, b = 0;
    for(auto p : d)
    {
        auto diff = p.first - x;
        if(d.find(diff) != d.end())
        {
            a = p.second;
            b = d[diff];
            break;
        }
    }

    cout << a << " " << b << endl;

    return 0;
}


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

string s;
int a[4];

bool dfs(int i, int sum, string sign){
  if(i == 4){
    if(sum != 7) return false;
    else{
      sign += "=";
      for(int i = 0; i < 4; i++) cout << a[i] << sign[i];
      cout << 7 << endl;
      return true;
    }
  }
  if(dfs(i+1, sum+a[i], sign+"+")) return true;
  if(dfs(i+1, sum-a[i], sign+"-")) return true;
  return false;
}

void solve(){
  for(int i = 0; i < 4; i++) a[i] = s[i]-'0';
  bool ans = dfs(1, a[0], "");
}

int main(){
  cin >> s;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

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

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;

ll x, k, d;

void code() {
    cin >> x >> k >> d;

    ll tmp = abs(x);
    ll div = tmp / d, rem = tmp % d;
    div++, rem -= d;

    if (k < div) {
        cout << abs(tmp - k * d) << "\n";
        return;
    }

    k -= div;
    // cout << k << "\n";
    if (k & 1 ^ 1)
        cout << abs(rem) << "\n";
    else {
        cout << min(abs(rem + d), abs(rem - d)) << "\n";
    }
}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int one_time = 1900 * M + 100 * (N - M);

    double AC_prob = 1.0 / pow(2, M);

    double ans = 0;

    for (int i = 1;;i++) {
        double x = AC_prob * pow(1 - AC_prob, i - 1) * one_time * i;
        ans += x;
        if (x < 0.00001) {
            break;
        }
    }
    cout << (long long)round(ans) << endl;
}

Measured memory_bytes: 640
s=list(input())
for i in range(len(s)):
    w=s[i]
    if w!="A" and w!="T" and w!="G" and w!="C":
        s[i]=" "
l="".join(s).split()
p=0
for i in l:
    if len(i) > p:
        p=len(i)
print(p)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll dp1[405][405];
ll dp2[405][405];
ll arr[405];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	for(ll i=1;i<=n;i++){
		dp1[i][i]=0;
		dp2[i][i]=arr[i];
	}
	for(ll i=2;i<=n;i++)
	{
		for(ll j=1;j<=(n-i+1);j++)
		{
			for(ll k=j;k<=(j+i-2);k++)
				if(k==j){
					dp1[j][j+i-1]=dp2[j][k]+dp2[k+1][j+i-1]+dp1[j][k]+dp1[k+1][j+i-1];
					dp2[j][j+i-1]=dp2[j][k]+dp2[k+1][j+i-1];
				}
				else{
					if((dp2[j][k]+dp2[k+1][j+i-1]+dp1[j][k]+dp1[k+1][j+i-1])<dp1[j][j+i-1])
					{
						dp1[j][j+i-1]=dp2[j][k]+dp2[k+1][j+i-1]+dp1[j][k]+dp1[k+1][j+i-1];
						dp2[j][j+i-1]=dp2[j][k]+dp2[k+1][j+i-1];
					}
				}

		}
	}
	/*for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
			cout<<dp1[i][j]<<" ";
		cout<<endl;
	}*/
	cout<<dp1[1][n]<<endl;

}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
static const int INF = 1e9;
int dp[1001][1001];

void solve()
{
	string s1, s2;
	cin >> s1 >> s2;
	int m = s1.size();
	int n = s2.size();
	for (int i = 0; i <= m; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i <= m; ++i)
	{
		dp[i][0] = i;
	}
	for (int i = 0; i <= n; ++i)
	{
		dp[0][i] = i;
	}
	for (int i = 1; i <= m; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			if (s1[i - 1] == s2[j - 1])
			{
				dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
			}
			else
			{
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
			}
		}
	}
	cout << dp[m][n] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 5100
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MOD 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define P pair<ll, ll>
#define VII vector<P>
#define P_B push_back

ll n;
ll v[101];
ll DP[100001];

int main() {
	
	// ll T; cin>>T; while(T--) 
	{
		
		ll k;
		cin>>n>>k;
		for (ll i = 0; i < n; i++) cin>>v[i];
		memset(DP, 0, sizeof(DP));
		DP[0] = 1;

		for (int i = 0; i < n; i++) {
			vector<int> pref(k+1, 0);

			for (int j = k; j >= 0; j--) {

				int tmp = DP[j];

				int l = j+1, r = j + min(k-j, v[i]);

				if(l <= r) {
					pref[l] = (pref[l] + tmp)%MOD;
					if(r+1 <= k) pref[r+1] = (pref[r+1] - tmp + MOD)%MOD;
				}
			}

			ll sum = 0;

			for (int j = 0; j <= k; j++) {
				sum = (sum +  pref[j])%MOD;
				DP[j] = (DP[j] + sum)%MOD;

			}
		}

		cout<<DP[k];
	}	
	return 0;
}

Measured memory_bytes: 4804
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    for (ll i = 0; i < 3 * n;i++){
        cin >> a[i];
    }
    ll sum = 0;
    sort(a.begin(), a.end());
    for (ll i = n * 3 - 2; i >= n;i-=2){
        sum += a[i];
    }
        cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
h = list(map(int,input().split()))
flg = [1]*n
for _ in range(m):
    a,b = map(int,input().split())
    if h[a-1] > h[b-1]:
        flg[b-1] = 0
    elif h[a-1] == h[b-1]:
        flg[a-1],flg[b-1] = 0,0
    else:
        flg[a-1] = 0
print(flg.count(1))

Measured memory_bytes: 19872
n = gets.chomp.to_i
hash = Hash.new(0)
n.times do |i|
    s = gets
    s = s.chomp
    if hash.include?(s)
        hash[s] += 1
    else
        hash[s] = 1
    end
    #p hash
end
hash_kai =  hash.sort_by{|i,j| j }
#p hash_kai
arr = []
#while true
count = 0
#p hash_kai
value = hash_kai[-1]
value = value[-1]
#p value
while true
    #p hash_kai
    if hash_kai != []
    key_value = hash_kai.pop
    else
        break
    end
    #p hash_kai
    if key_value != []
        if value == key_value[-1]
        arr << key_value[0]
        else
            break
        end
    else
        break
    end
    count += 1
end
arr = arr.sort
arr.each  {|i| puts i}

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

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

const int MAXN = (int)1e5 + 10;
int n, k, ans[MAXN];
vector<II> adj[MAXN];

void dfs(int u, int p = -1, int p_color = -1) {
    int current_color = 0;
    for (int i = 0; i < (int)adj[u].size(); ++i) {
        int v = adj[u][i].first;
        int w = adj[u][i].second;
        if (v != p) {
            current_color += 1;
            if (current_color == p_color) {
                current_color += 1;
            }
            ans[w] = current_color;
            dfs(v, u, current_color);
        }
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n - 1; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        adj[u].push_back(II(v, i));
        adj[v].push_back(II(u, i));
    }

    k = 0;
    for (int i = 1; i <= n; ++i) {
        k = max(k, (int)adj[i].size());
    }
    dfs(1);

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


Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int bubbleSort(vector<int> &a, int n)
{
	bool flag = true;
	int count = 0;
	while (flag)
	{

		flag = false;
		for (int j = n - 1; j > 0; --j)
		{
			if (a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				flag = true;
				count++;
			}
		}
	}
	return count;
}

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

	string A;
	getline(cin, A);

	vector<int> va;

	istringstream iss(A);
	while (!iss.eof())
	{
		int t;
		iss >> t;
		iss.ignore();
		va.push_back(t);
	}
	int count = bubbleSort(va, N);
	ostringstream oss;
	for (int i = 0; i < va.size() - 1; ++i)
	{
		oss << va[i] << " ";
	}
	oss << va[va.size() - 1] << endl;

	cout << oss.str();
	cout << count << endl;
	return 0;
}

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

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

  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }

}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var (
    n int
    count int
    sum int
  )
  fmt.Scan(&n)
  a := make([]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&a[i])
    if a[i] < 0 {
      count++
    }
  }

  tmp_r := make([]int,n)
  for i:=0;i<n;i++ {
    if a[i] < 0 {
      sum -= a[i]
      tmp_r[i] = -a[i]
    } else {
      sum += a[i]
      tmp_r[i] = a[i]
    }
  }

  min := tmp_r[0]
  for i:=1;i<n;i++ {
    if min > tmp_r[i] {
      min = tmp_r[i]
    }
  }
  if count % 2 == 0 {
    fmt.Println(sum)
  } else {
    fmt.Println(sum- 2*min)
  }




}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 100005
int n,m,p[N],ans,tim,col[N],head[N],cnt;
struct edge{int to,nxt;}e[N<<1];
void adde(int x,int y){e[++cnt].to=y;e[cnt].nxt=head[x];head[x]=cnt;}
void ins(int x,int y){adde(x,y);adde(y,x);}
void dfs(int u){
	col[u]=tim;
	for (int i=head[u],v;i;i=e[i].nxt) if (!col[v=e[i].to]) dfs(v);
}
int main(){
	n=read(),m=read();
	rep (i,1,n) p[i]=read();
	rep (i,1,m){int x=read(),y=read();ins(x,y);}
	rep (i,1,n) if (!col[i]) tim++,dfs(i);
	rep (i,1,n) if (col[i]==col[p[i]]) ans++;
	cout<<ans<<'\n';
	return 0;
}

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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 998244353 
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int a[5];
    int sum = 15;
    F(i, 0, 5)
    {
    	int x;
    	SI(x);
    	sum -= x;
    }
    SO(sum);
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        
        String ans = "";
        long a = 2;
        long b = 0;
        while(n != 0){
            if(n%(a<<b) != 0){
                ans = "1" + ans;
                if(b%2 == 0){
                    n -= (a>>1)<<b;
                }else{
                    n += (a>>1)<<b;
                }
            }else{
                ans = "0" + ans;
            }
            b++;
        }
        
        if(ans.length() == 0){
            System.out.println(0);
        }else{
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=305;
const ll inf=1e18;
int n,k,h[max_n];
ll dp[max_n][max_n];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",h+i);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++)dp[i][j]=inf;
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            for(int k=0;k<i;k++){
                dp[i][j]=min(dp[i][j],dp[k][j-1]+max(h[i]-h[k],0));
            }
        }
    }
    ll ans=inf;
    for(int i=0;i<=n;i++)ans=min(ans,dp[i][n-k]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<LL> value(1<<18), weight(1<<18);
  FOR(i,1,n+1) cin >> value[i] >> weight[i];
  vector<vector<pair<LL, LL>>> hanzen(1<<13); // weight, value
  hanzen[0].emplace_back(0,0);
  FOR(bits,1,1<<13) {
    for(pair<LL,LL> p:hanzen[bits/2]) {
      pair<LL,LL> added = make_pair(p.first+weight[bits], p.second+value[bits]);
      hanzen[bits].push_back(p);
      hanzen[bits].push_back(added);
    }
    vector<pair<LL,LL>> tmp(hanzen[bits].begin(),hanzen[bits].end());
    sort(tmp.begin(),tmp.end());
    hanzen[bits].clear();
    hanzen[bits].emplace_back(0,0);
    for(pair<LL,LL> p:tmp) {
      if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);
    }
  }
  int q;
  cin >> q;
  while(q--) {
    LL v, l;
    cin >> v >> l;
    vector<pair<LL,LL>> comb;
    comb.emplace_back(0,0);
    while(v>=(1<<13)) {
      vector<pair<LL,LL>> tmp(comb.begin(), comb.end());
      for(pair<LL,LL> p:tmp) {
        pair<LL,LL> added = make_pair(p.first+weight[v], p.second+value[v]);
        comb.push_back(added);
      }
      v/=2;
    }
    LL answer = 0;
    for(pair<LL,LL> p: comb) {
      LL cw,cv;
      tie(cw,cv) = p;
      if(cw>l) continue;
      auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));
      --ite;
      answer=max(answer, cv+ite->second);
    }
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 607656
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string>
#include <numeric>
using namespace std;

int main()
{
	int N, X;
	cin >> N >> X;
	int res = 0;
	vector<int> m(N);
	for (int i = 0;i < N;i++) {
		cin >> m[i];
	}
	int Xa = X - accumulate(m.begin(), m.end(),0);
	sort(m.begin(), m.end());
	res =N +Xa / m[0];
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <functional>

using lint = long long;

template <class Container>
std::vector<int> zalgo(const Container& dat) {
    int n = dat.size();

    std::vector<int> ret(n);
    ret[0] = n;

    int i = 1, len = 0;
    while (i < n) {
        while (i + len < n && dat[len] == dat[i + len]) {
            ++len;
        }
        ret[i] = len;

        if (len == 0) {
            ++i;
            continue;
        }

        int nlen = 1;
        while (i + nlen < n && nlen + ret[nlen] < len) {
            ret[i + nlen] = ret[nlen];
            ++nlen;
        }

        i += nlen;
        len -= nlen;
    }

    return ret;
}

void solve() {
    std::string s;
    std::cin >> s;

    auto pcount = [&](int len) -> std::vector<lint> {
        std::vector<lint> ret(26, 0);
        for (int i = 0; i < len; ++i) {
            ++ret[s[i] - 'a'];
        }
        return ret;
    };

    int len = s.length();
    int slen = len / 2;

    auto zs = zalgo(s);
    int tlen;
    for (tlen = slen + 1; tlen < len; ++tlen) {
        if (zs[tlen] == len - tlen) break;
    }

    std::function<std::vector<lint>(lint)> count;

    if (tlen == slen * 2) {
        count = [&](lint len) -> std::vector<lint> {
            auto ret = pcount(slen);

            for (auto& x : ret) x *= len / slen;
            len %= slen;

            auto pcnt = pcount(len);
            for (int i = 0; i < 26; ++i) {
                ret[i] += pcnt[i];
            }

            return ret;
        };

    } else {
        count = [&](lint len) -> std::vector<lint> {
            std::vector<std::vector<lint>> cnts{pcount(slen), pcount(tlen)};
            std::vector<lint> lens{slen, tlen};

            while (lens.back() < len) {
                int n = lens.size();

                auto cnt1 = cnts[n - 2],
                     cnt2 = cnts[n - 1];

                std::vector<lint> cnt(26, 0);
                for (int i = 0; i < 26; ++i) {
                    cnt[i] = cnt1[i] + cnt2[i];
                }
                cnts.push_back(cnt);

                auto len1 = lens[n - 2],
                     len2 = lens[n - 1];
                lens.push_back(len1 + len2);
            }

            std::vector<lint> ret(26, 0);

            int n = lens.size();
            for (int i = n - 1; i >= 0; --i) {
                if (len < lens[i]) continue;

                for (int c = 0; c < 26; ++c) {
                    ret[c] += cnts[i][c];
                }
                len -= lens[i];
            }

            auto pcnt = pcount(len);
            for (int i = 0; i < 26; ++i) {
                ret[i] += pcnt[i];
            }

            return ret;
        };
    }

    lint l, r;
    std::cin >> l >> r;

    auto rs = count(r),
         ls = count(l - 1);

    for (int i = 0; i < 26; ++i) {
        std::cout << rs[i] - ls[i] << " ";
    }
    std::cout << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AWeatherPrediction solver = new AWeatherPrediction();
        solver.solve(1, in, out);
        out.close();
    }

    static class AWeatherPrediction {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            String s = in.scanString();
            if (s.charAt(0) == 'S') out.println("Cloudy");
            else if (s.charAt(0) == 'C') out.println("Rainy");
            else out.println("Sunny");
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 20948
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

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

    int ans = 1<<29;
    for (int i = 0; i <= 1; i++) {
        int a = i;
        int count = 0;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] - '0' != a) count++;
            a = 1 - a;
        }
        ans = min(ans, count);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] L = new int[N];

		int iMax = 0;
		int sum = 0;
		for (int i = 0; i < L.length; i++) {
			L[i] = sc.nextInt();
			sum += L[i];
			if (L[iMax] < L[i]) {
				iMax = i;
			}
		}

		System.out.println(L[iMax] < sum - L[iMax] ? "Yes" : "No");

		sc.close();
	}

}




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

using ll = long long;

const int N = 200005, SZ = 262144;
const ll INF = ll(1e18);

int n, q;
ll a[N], b[N];

struct Seg{
  ll d[2*SZ][2];
  void m(ll *a, ll *b, ll *r){
    ll c[2] = {-INF, -INF};
    for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++){
      c[i^j] = max(c[i^j], a[i] + b[j]);
    }
    r[0] = c[0];
    r[1] = c[1];
  }
  void u(int x, int a, int b){
    x += SZ;
    d[x][0] = a;
    d[x][1] = b;
    for(x /= 2; x; x /= 2) m(d[2*x], d[2*x+1], d[x]);
  }
  ll g(int s, int e){
    ll r[2] = {0, -INF};
    for(s += SZ, e += SZ; s <= e; s /= 2, e /= 2){
      if(s % 2 == 1) m(r, d[s++], r);
      if(e % 2 == 0) m(r, d[e--], r);
    }
    return r[0];
  }
} S;

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

  cin >> n >> q;
  n *= 2;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) cin >> b[i];

  for(int i = 1; i <= n; i++) S.u(i, a[i], b[i]);

  for(; q--; ){
    int x;
    ll y, z;
    cin >> x >> y >> z;
    S.u(x, y, z);
    cout << S.d[1+SZ][0] + S.g(2, n - 1) + S.d[n+SZ][0] << '\n';
  }

  return 0;
}

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS

ll n,k,i=0,j;
double count;
cin>>n>>k;
while(n--)
{ll a,b;
cin>>a>>b;
j=(a*a)+(b*b);
count=sqrt(j);
if(count<=k)
{
    i++;
}

}
cout<<i;


return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
typedef long long ll;
typedef long double ld;
using namespace std;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

int p[101];

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

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      p[i * j] = 1;
    }
  }

  int n;
  cin >> n;
  cout << (p[n] ? "Yes" : "No") << endl;

  return 0;
}

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



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

    int ans;
    for(int i = 0; i < s.size(); i++) {
        set<char> sc1;
        set<char> sc2;
        int ret = 0;
        for(int j = 0; j < s.size(); j++) {
            if(j < i) sc1.insert(s[j]);
            else sc2.insert(s[j]);
        }
        for(auto e : sc1) {
            if(sc2.find(e) != sc2.end()) ret++;
        }
        ans = max(ans, ret);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace B
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] tmp = Console.ReadLine().Split(' ');
			long n = long.Parse(tmp[0]);
			long a = long.Parse(tmp[1]);
			long b = long.Parse(tmp[2]);

			Console.WriteLine(n/(a+b)*a + Math.Min(a, n%(a+b)));
		}
	}
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
int main(void)
{
  int X, i, count = 0;

  scanf("%d", &X);
  while (1)
  {
    for (i = 2; i <= X / 2; i++)
    {
      if (X % i == 0)
        count = 1;
    }
    if (count == 0)
    {
      break;
    }
    else
    {
      X++;
      count = 0;
    }
  }
  printf("%d", X);
  return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

ll p(ll a, ll mod) {
    ll res = 1;
    for (ll i = a; i > 0; i--) {
        res *= i;
        res %= mod;
    }
    return res;
}

void solve() {
    int N, M;
    cin >> N >> M;

    int diff = abs(N - M);
    if (diff > 1) {
        print(0);
    } else {
        ll a, b;
        a = min(N, M);
        b = max(N, M);
        const ll mod = 1000000007; 
        ll ans;
        if (a == b) {
            ans = p(a, mod) * 2 * p(b, mod);
        } else {
            ans = p(a, mod) * p(b, mod);
        }
        print(ans%mod);
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256