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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  int M = SZ(S);
  VI ds(M+1);
  ds[0] = S[0] - 'a';
  for(int i=1;i<M;++i){
	int b = S[i] - 'a';
	int a = S[i-1] - 'a';
	ds[i] = (b - a + 26) % 26;
  }
  ds[M] = (26 - (int)(S.back() - 'a')) % 26;
  
  VVI G(M+1);
  for(int i=0;i<(M+1)/2;++i){
	G[i].PB(M - i);
	G[M-i].PB(i);
  }

  int N;
  cin >> N;
  REP(i,N){
	int l, r;
	cin >> l >> r;
	--l;
	G[l].PB(r);
	G[r].PB(l);
  }

  vector<bool> vis(M+1);
  function<int(int)> dfs = [&](int u){
	int res = ds[u];
	vis[u] = true;
	for(int to: G[u]){
	  if(vis[to]) continue;
	  res += dfs(to);
	}
	return res;
  };

  bool ng = false;
  REP(i,M+1){
	if(vis[i]) continue;
	if(dfs(i) % 26 != 0){
	  ng = true;
	  break;
	}
  }
  cout << (ng? "NO": "YES") << endl;

  return 0;
}


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

typedef long long       ll;
typedef vector<int>     vi;
typedef pair<int,int>   pi;
typedef map<int,int>    mi;

#define F               first
#define S               second
#define pb              push_back
#define mp              make_pair
#define M               1000000007
#define SQ(a)           (a)*(a)
#define rep(i,a,b)      for(int i=a; i<b; i++)

void solve(){
    int k;
    cin >> k;
    string s = "";

        for (int i=0; i<k; i++) s+="ACL";
    cout  << s << endl;
}
int main(){
    //int t; cin >> t; while(t--)
    solve();

    return 0;
}






Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int n,i,j,k;
int f[100005],son[100005],Next[100005];
int id[100005];

inline bool cmp(const int &a,const int &b){return f[a]>f[b];}

void dfs(int x)
{
	if(!son[x])return;
	int i,j,k=0;
	for(i=son[x];i;i=Next[i])dfs(i);
	for(i=son[x];i;i=Next[i])id[++k]=i;
	sort(id+1,id+k+1,cmp);
	for(i=1;i<=k;++i)
	{
		j=f[id[i]]+i;
		if(j>f[x])f[x]=j;
	}
}

int main()
{
	scanf("%d",&n);
	for(i=2;i<=n;++i)scanf("%d",&k),Next[i]=son[k],son[k]=i;
	dfs(1);
	printf("%d\n",f[1]);
}

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

typedef long long int ll;
using ii= pair<ll,ll>;
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001
#define mod 1000000007

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};


int main()
{
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
        auto start= high_resolution_clock::now();
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    cout<<max({a*c,a*d,b*c,b*d})<<"\n";





    
    #ifndef ONLINE_JUDGE
        auto stop= high_resolution_clock::now();
        auto duration= duration_cast<milliseconds>(stop-start);
        cout<<"run time: "<<duration.count()<<" ms"<<"\n";
    #endif
}

Measured memory_bytes: 3640
N,X = map(int,input().split())

m = [int(input()) for i in range(N)]

m.sort()


dounut = 0#消費した素の量
count = 0 #追加で作った数
for i in range(N):
    dounut = dounut + m[i]

while dounut < X:
        dounut = dounut + m[0]
        count += 1

if dounut >  X:
    count -= 1

print(N + count)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

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

  string res = "";
  rep(i, s.size()) {
    if (i % 2 == 0) res += s[i];
  }

  cout << res << endl;
}

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

int main() {
	//入力
	int n;
	cin >> n;
	vector<int> a(n+1);
	rep(i, n) cin >> a[i];

	//答え
	ll kane = 1000;
	for (int i = 0;i < n;++i) {
		if (a[i + 1] > a[i]) {
			//次が上がるならa[i]で買いa[i+1]で売る
			ll kabu = kane / a[i];
			kane -= (ll)a[i] * kabu;
			kane += (ll)a[i+1] * kabu;
		}
	}

	cout << kane << endl;
}


Measured memory_bytes: 3636
W = input().lower()

text = ""; all_text = ""
while text != "END_OF_TEXT":
    text = input()
    all_text += text + " "
    
T = list(all_text.lower().split())[:-1]


count = 0
for i, text in enumerate(T):
    if W == text:
        count += 1

print(count)


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

int main(){
    int N;
    cin >> N;
    if(N<105) cout << "0" << endl;
    else if(N<135) cout << "1" << endl;
    else if(N<165) cout << "2" << endl;
    else if(N<189) cout << "3" << endl;
    else if(N < 195) cout << "4" << endl;
    else cout << "5" << endl;
    return 0;
}

Measured memory_bytes: 384
import itertools

# print('input >>')
N = int(input())
Ls = list(map(int,(input().split())))
Ls.sort()

combs = itertools.combinations(Ls, 3)

ans = 0
for comb in combs:
    if (comb[0] != comb[1] and comb[1] != comb[2] and comb[2] != comb[0] 
      and comb[0] + comb[1] > comb[2]):
        ans += 1

# print('-----output-----')
print(ans)

Measured memory_bytes: 9212
import bisect
import math
N = int(input())

def diviser(n):
    div = 0
    for i in range(1, n+1):
        if n % i == 0:
            div += 1
    return div

l = []
for i in range(1, 201):
    if i % 2 == 1:
        if diviser(i) == 8:
            l.append(i)
print(bisect.bisect_right(l, N))

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))

cnt = 0
e = 0
while e == 0:
  for i in range(n):
    if a[i] % 2 == 0:
      a[i] = a[i]/2
      if i == n-1:
        cnt += 1
        
    else:
      e = 1
      break
      
print(cnt)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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; }

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

	ll N, A, B;
	cin >> N >> A >> B;

	vl H(N);
	ll diff = A - B;

	rep(i, N) {
		cin >> H[i];
	}

	ll m = *max_element(H.begin(), H.end());
	m = (ceil((double)m / B));
	ll min = m;
	m = m / 2 + 1;
	ll T = m;

	ll max = 0;

	ll c;

	while ((min-max) != 1) {

		c = 0;
		rep(i, N) {
			if (H[i] > T * B) {
				c += ceil((H[i] - T * B) / (double)diff);
			}
		}

		m = m >> 1;
		if (m == 0)m = 1;

		if(c > T){
			chmax(max, T);
			T += m;
		}
		else {
			chmin(min, T);
			T -= m;
		}
	}

	cout << min << endl;


	return 0;
}



Measured memory_bytes: 1024
import java.io.*;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args) throws IOException {

        int n = 0;
        int m = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] line = br.readLine().split(" ");
        n = Integer.parseInt(line[0]);
        m = Integer.parseInt(line[1]);

        int num_a[][];
        num_a = new int[n][m];

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

            String[] line1 = br.readLine().split(" ");

            for (int x = 0; x < m; x++) {
                num_a[i][x] = Integer.parseInt(line1[x]);
            }

        }
        
        int num_b[];
        int num_c[];
        num_b = new int[m];
        num_c = new int[n];
        
        for(int i = 0; i < m; i++) {
            num_b[i] = Integer.parseInt(br.readLine());
        }
        
        
        for(int i = 0; i < n; i++) {
            
            for(int x = 0; x < m; x++) {
                num_c[i] += num_a[i][x] * num_b[x];
            }
           
        }
        
        for(int i = 0; i < n; i++) {
            System.out.println(num_c[i]);
        }
    }

}

Measured memory_bytes: 27676
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int M = sc.nextInt();
    List<Integer> A = new ArrayList<>();
    int[][] BC = new int[M][2];

    for (int i = 0; i < N; i++) {
      A.add(sc.nextInt());
    }

    for (int i = 0; i < M; i++) {
      int B_ = sc.nextInt();
      int C_ = sc.nextInt();
      BC[i][0] = B_;
      BC[i][1] = C_;
    }

    sc.close();

    Arrays.sort(BC, (a,b) -> Integer.compare(b[1],a[1]));

    int count = 0;

    roop: for (int i = 0; i < M; i++) {
      for (int j = 0; j < BC[i][0]; j++) {
        A.add(BC[i][1]);
        count++;
        if (N <= count){
          break roop;
        }
      }
    }

    Collections.sort(A, Comparator.reverseOrder());
    
    long sum = 0;

    for (int i = 0; i < N; i++) {
      sum += A.get(i);
    }

    System.out.println(sum);

  }

}

Measured memory_bytes: 102652
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
    int N;
    cin>>N;
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<N-2;i++){
        string t=s.substr(i,3);
        if(t=="ABC"){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define mid (start+end)/2
#define fi first
#define se second
ll MAXI=1e6+10;
ll MOD=998244353;
ll exp(ll n, ll e)
{
	if (e==0)
		return 1;
	ll temp=exp((n*n)%MOD,e/2);
	return e%2==0 ? temp :(temp*n)%MOD;
}
ll inverse(ll n)
{
	return exp(n,MOD-2);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	v arr(n+1);
	v count(MAXI,0);
	for (int i=1; i<=n; i++)
	{
		cin>>arr[i];
		count[arr[i]]++;
	}
	v a(MAXI,0);
	v b(MAXI,0);
	for (int i=1; i<MAXI; i++)
	{
		for (int j=i; j<MAXI; j+=i)
		{
			a[i]+=(j*count[j])%MOD;
			b[i]+=((j*count[j])%MOD*j)%MOD;
			a[i]%=MOD;
			b[i]%=MOD;
		}
	}
	ll c=(MOD+1)/2;
	for (int i=1; i<MAXI; i++)
	{
		a[i]=((((a[i]*a[i])%MOD-b[i]+MOD)%MOD)*c)%MOD;
	} 
	v f(MAXI,0);
	ll ans=0;
	v inv(MAXI);
	for (int i=1; i<MAXI; i++)
	{
		inv[i]=inverse(i);
	}
	for(int i=MAXI-1; i>=1; i--)
	{
		f[i]=a[i];
		for (int j=2*i;j<MAXI; j+=i)
		{
			f[i]=(f[i]-f[j]+MOD)%MOD;
		}
		ans=(ans+f[i]*inv[i])%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 43008
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int L = 0;
        int R = 0;
        for(int i = 0; i < n; i++) {
            String s1 = stdIn.next();
            String s2 = stdIn.next();
             
            if(s1.compareTo(s2) == 0) {
                L++;
                R++;
            }
            else if(s1.compareTo(s2) < 0) {
                L += 3;
            }
            else {
                R += 3;
            }
        }
         
        System.out.println(R + " " + L);
    }
}


Measured memory_bytes: 29580
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N,MAX,ans;cin>>N;
    MAX=ans=0;
    REP(i,N){
        int a;cin>>a;
        ans+=a;
        MAX=max(MAX,a);
    }
    cout<<ans-MAX/2<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int ms[15][15] , count , n;

void ms_f(int x , int y){
	int bx , by;
	ms[y][x] = count++;
	bx = (x+1) % n;
	by = (y+1) % n;
	if((x==(n-1)/2)&&(y==(n-3)/2)) return;
	if(ms[by][bx]==0){
		ms_f(bx , by);
	}else{
		ms_f(x , (y+2)%n);
	}
}

int main(void){
	int i , j;
	while(1){
		scanf("%d" , &n);
		if(n==0) break;
		count = 1;
		for(i=0;i<15;i++){
			for(j=0;j<15;j++){
				ms[i][j] = 0;
			}
		}
		ms_f((n-1)/2 , (n+1)/2);
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				printf("%4d" , ms[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=200010;
int n,a[MAXN];
ll ans,cnt[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		ans+=cnt[a[i]];
		cnt[a[i]]++;
	}
	for (int i=1;i<=n;i++) {
		printf("%lld\n",ans-cnt[a[i]]+1);
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define MAX 100005

using namespace std;

int cur_ans;
int N, K, intval;
char s[MAX];

int main() {
	ios::sync_with_stdio(0);
	cin >> N >> K;
	cin >> (s + 1);
	for(int i = 1; i <= N; ++i) {
		if(s[i] == 'R') {
			if(s[i - 1] != 'R') ++intval;
			if(s[i + 1] == 'R') ++cur_ans;
		} else {
			if(s[i - 1] == 'L') ++cur_ans;
		}
	}
	if(s[1] == 'R' && s[N] == 'R') {
		--intval;
		if(K < intval) cur_ans += K * 2;
		else cur_ans = N - 1;
	} else {
		if(K < intval) cur_ans += K * 2;
		else cur_ans = N - 1;
	}
	cout << cur_ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <array>

using namespace std;

int main() {
  array<bool, 200000> arr;
  fill(arr.begin(), arr.end(), true);

  for (int i = 2; i < static_cast<int>(arr.size()); ++i) {
    if (not arr[i])
      continue;
    for (int j = i * 2; j < static_cast<int>(arr.size()); j+= i)
      arr[j] = false;
  }

  int x;
  cin >> x;
  int i = x;
  while (not arr[i++]);
  cout << i - 1 << endl;
}

Measured memory_bytes: 384
s = list(input())
chk1 = 0
chk2 = 0

bk = []
for i in range(len(s)):
  if i%2 == 0:
    bk.append('1')
  else :
    bk.append('0')
    
    
for i in range(len(s)):
  if bk[i] == s[i]:
    chk1 += 1
  else :
    chk2 += 1
print(min(chk1,chk2))


Measured memory_bytes: 4652
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long K = sc.nextLong();
		long x = K % 50, y = K /50;
		long[] a = new long[50];
		for(int i = 0; i < 50; i++) {
			a[i] = i + y;
			if(i >= 50 - x)
				a[i]++;
		}
		System.out.println(50);
		for(int i = 0; i < 50; i++)
			System.out.print(a[i] + " ");
	}

}

Measured memory_bytes: 38804
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    n %= 10;
    set<int> s{0, 1, 6, 8};
    if (n == 3) {
        cout << "bon" << '\n';
    } else if (s.count(n)) {
        cout << "pon" << '\n';
    } else {
        cout << "hon" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3628
/* ***************************************
Author        :Scau.ion
Created Time  :2017/10/10 15:53:54 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const int maxn = 100010;

VI son[maxn];

bool vis[maxn], col[maxn];
int sum;

bool dfs(int x, bool co)
{
	if (vis[x])
	{
		if (co != col[x]) return 0;
		return 1;
	}
	vis[x] = 1;
	col[x] = co;
	if (co) ++ sum;
	for (int j = 0; j < son[x].size(); ++ j)
		if (0 == dfs(son[x][j], !co)) return 0;
	return 1;
}

int main()
{
	IOS;
	int n, m;
	cin>>n>>m;
	for (int j = 1; j <= m; ++ j)
	{
		int u, v;
		cin>>u>>v;
		son[u].PB(v);
		son[v].PB(u);
	}
	LL ans = 0;
	if (dfs(1, 0)) ans = (LL)sum * (n - sum);
	else ans = (LL)n * (n - 1) / 2;
	ans -= m;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int > c(n);
    vector<vector<int>> a(n, vector<int>(m, 0));

    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    int ans = INF;
    for (int bit = 0; bit < (1 << n); bit++) {
        int sum = 0;
        vector<int> b(m);
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                sum += c[i];
                rep(j, m) {
                    b[j] += a[i][j];
                }
            }
        }
        
        bool ok = true;
        rep(i, m) {
            if (b[i] < x) ok = false;
        }
        if (ok) chmin(ans, sum);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
typedef long long ll;

ll N;

ll solve(ll N) {
  ll M=1000-N;
  ll ans=0;
  ll a=M/500;
  M-=a*500;
  ll b=M/100;
  M-=b*100;
  ll c=M/50;
  M-=c*50;
  ll d=M/10;
  M-=d*10;
  ll e=M/5;
  M-=e*5;
  return a+b+c+d+e+M;
}
  

int main() {
  while(cin>>N) {
    if (N) cout<<solve(N)<<endl;
    else break;
  }
  return 0;
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long

int est[2][100010], dis[100010], ans[100010];
vector<vector<int>> seg(2, vector<int>(524288, 0)), cseg = seg;
vector<tuple<int, int, int, int, int, int>> QC[100010];
vector<tuple<int,int,int>> G[100010];//目次:頂点　連結先、色、距離
vector<pair<int, int>> VC[100010];//目次:色　子、距離
vector<int> Euler;

void eval(int x, vector<vector<int>>& Vec) {
	Vec[0][x] += Vec[1][x];
	if (x < 262144) {
		Vec[1][x * 2] += Vec[1][x];
		Vec[1][x * 2 + 1] += Vec[1][x];
	}
	Vec[1][x] = 0;
}

void sadd(int s, int t, int v, vector<vector<int>>& Vec, int l = 0, int r = 262143, int x = 1) {
	eval(x, Vec);
	if (r < s || t < l)return;
	if (s <= l && r <= t) {
		Vec[1][x] += v;
		eval(x, Vec);
		return;
	}
	sadd(s, t, v, Vec, l, (l + r) / 2, x * 2);
	sadd(s, t, v, Vec, (l + r) / 2 + 1, r, x * 2 + 1);
	Vec[0][x] = min(Vec[0][x * 2], Vec[0][x * 2 + 1]);
}

tuple<int,int,int> smin(int s, int t, vector<vector<int>>& Vec, int x = 1, int l = 0, int r = 262143) {
	eval(x, Vec);
	if (r < s || t < l)return make_tuple(INT32_MAX, l, r);
	if (s <= l && r <= t) {
		return make_tuple(Vec[0][x], l, r);
	}

	auto lv = smin(s, t, Vec, x * 2, l, (l + r) / 2);
	auto rv = smin(s, t, Vec, x * 2 + 1, (l + r) / 2 + 1, r);
	if (lv < rv) {
		return lv;
	}
	else {
		return rv;
	}
}

void EulerTour(int c, int p, int&cnt) {
	int i, j, k;
	sadd(cnt, cnt, dis[c], seg);
	est[0][c] = cnt;
	est[1][c] = cnt;
	cnt++;
	for (auto x : G[c]) {
		tie(i, j, k) = x;
		if (i == p)continue;
		dis[i] = dis[c] + k;
		VC[j].push_back({ i,k });
		EulerTour(i, c, cnt);
		sadd(cnt, cnt, dis[c], seg);
		est[1][c] = cnt;
		cnt++;
	}
}

int main(){
	int N, Q;
	cin >> N >> Q;
	int a, b, c, d;
	for (int i = 1;i < N;i++) {
		cin >> a >> b >> c >> d;
		G[a].push_back(make_tuple(b, c, d));
		G[b].push_back(make_tuple(a, c, d));
	}
	int sz = 0;
	EulerTour(1, 0, sz);

	int x, y, u, v, Y, v1, v2, v3;
	for (int i = 0;i < Q;i++) {
		cin >> x >> y >> u >> v;
		auto X = smin(min(est[0][u], est[0][v]), max(est[0][u], est[0][v]), seg);
		tie(ignore, a, b) = X;
		QC[x].push_back(make_tuple(y, u, v, a, b, i));
	}

	for (int i = 1;i < N;i++) {
		for (auto au : VC[i]) {
			tie(a, d) = au;
			sadd(est[0][a], est[1][a], -d, seg);
			sadd(est[0][a], est[1][a], 1, cseg);
		}

		for (auto au : QC[i]) {
			tie(y, u, v, a, b, Y) = au;

			v1 = get<0>(smin(est[0][u], est[0][u], seg)) + get<0>(smin(est[0][u], est[0][u], cseg)) * y;
			v2 = get<0>(smin(est[0][v], est[0][v], seg)) + get<0>(smin(est[0][v], est[0][v], cseg)) * y;
			v3 = get<0>(smin(a, b, seg)) + get<0>(smin(a, b, cseg)) * y;
			ans[Y] = v1 + v2 - v3 * 2;
		}

		for (auto au : VC[i]) {
			tie(a, d) = au;
			sadd(est[0][a], est[1][a], d, seg);
			sadd(est[0][a], est[1][a], -1, cseg);
		}
	}
	for (int i = 0;i < Q;i++) {
		cout << ans[i] << endl;
	}
}

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

int main()
{
    string s;
    cin>>s; int d=0;
    for(int i=0; i<s.size(); i++)
        if(s[i]=='7') d=1;
    if(d) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
	int a = -1;
	int count = 1;
	do
	{
		scanf("%d", &a);
		if (a == 0)
		{
			break;
		}
		printf("Case %d: %d\n",count,a);
		count += 1;
	} while (a != 0);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0

using namespace std;

int h, w, n;
string s, t;


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int x, y;
    cin >> h >> w >> n >> x >> y >> s >> t;
    int possible_left = y, possible_right = y;
    int possible_up = x, possible_down = x;
    
    
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'L')
        {
            possible_right -= 1;
        }
        else if(s[i] == 'R')
        {
            possible_left += 1;
        }
        else if(s[i] == 'U')
        {
            possible_down -= 1;
        }
        else if(s[i] == 'D')
        {
            possible_up += 1;
        }
        
        if(possible_right < 1)
        {
            cout << "NO" << endl; return 0;
        }
        if(possible_left > w)
        {
            cout << "NO" << endl; return 0;
        }
        if(possible_up > h)
        {
            cout << "NO" << endl; return 0;
        }
        if(possible_down < 1)
        {
            cout << "NO" << endl; return 0;
        }
        
        
        
        
        if(t[i] == 'L')
        {
            possible_left = max(1, possible_left - 1);
        }
        else if(t[i] == 'R')
        {
            possible_right = min(w, possible_right + 1);
        }
        else if(t[i] == 'U')
        {
            possible_up = max(1, possible_up - 1);
        }
        else if(t[i] == 'D')
        {
            possible_down = min(h, possible_down + 1);
        }
        
    }
    
    
    
    
    
    cout << "YES" << endl;
    return 0;
}


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

typedef pair<long long, long long> pi;
typedef pair<long long, pi> pii;

long long n, c, p[100000];
pii a[100000];
vector<pii> edges;

long long root(long long x){
	return p[x] == -1 ? x : p[x] = root(p[x]);
}

void connect(long long x, long long y){
	p[root(x)] = root(y);
}

bool cmp1(pii a, pii b){
	return a.second.first < b.second.first;
}

bool cmp2(pii a, pii b){
	return a.second.second < b.second.second;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){ cin >> a[i].second.first >> a[i].second.second; a[i].first = i; }
	sort(a, a+n, cmp1);
	for(int i = 1; i < n; i++) edges.push_back(pii(min(abs(a[i].second.first-a[i-1].second.first), abs(a[i].second.second-a[i-1].second.second)), pi(a[i].first, a[i-1].first)));
	sort(a, a+n, cmp2);
	for(int i = 1; i < n; i++) edges.push_back(pii(min(abs(a[i].second.first-a[i-1].second.first), abs(a[i].second.second-a[i-1].second.second)), pi(a[i].first, a[i-1].first)));
	sort(edges.begin(), edges.end());
	memset(p, -1, sizeof(p));
	for(auto &it : edges){
		if(root(it.second.first) != root(it.second.second)){
			c += it.first;
			connect(it.second.first, it.second.second);
		}
	}
	cout << c;
}


Measured memory_bytes: 10864
N, K = map(int, input().split())
S = input()
new_S = []
count_S = []

cur_c = S[0]
cur_count = 0

new_S.append(cur_c)
for c in S:
    if c == cur_c:
        cur_count += 1
    else:
        new_S.append(c)
        count_S.append(cur_count)
        cur_count = 1
        cur_c = c
count_S.append(cur_count)        

new_count = []
st_ix = 0
if S[0] == '0':
    cur_sum = sum(count_S[:2*K])
    st_ix = 1
    new_count.append(cur_sum)
else:
    cur_sum = sum(count_S[:2*K+1])
    new_count.append(cur_sum)

en_ix = st_ix + 2*K + 1
cur_sum = sum(count_S[st_ix:en_ix])
new_count.append(cur_sum)

while en_ix < len(count_S):
    # shift st_ix
    st_ix = st_ix + 2
    en_ix = en_ix + 2
    if en_ix >= len(count_S):
        new_count.append(sum(count_S[st_ix:]))
    else:
        cur_sum -= (count_S[st_ix-2] + count_S[st_ix-1])
        cur_sum += (count_S[en_ix-2]
                        + count_S[en_ix-1])
    new_count.append(cur_sum)

print(max(new_count))


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

int main(){
	ios::sync_with_stdio(false);
	int N,X,T; cin>>N>>X>>T;

	int tako=0;
	int ct=0;
	while(tako<N){
		ct++;
		tako += X;
	}
	cout << ct*T << endl;

}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    
    unordered_map<string, long long int> m; 
    for(int i=0; i<n; i++){
        string temp;
        cin >> temp;
        sort(temp.begin(), temp.end());
        m[temp]++;
    }

    long long int ans = 0;
    for(auto e:m){
        long long int n = e.second;
        ans += ((n*(n-1))/2);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 10660
import sys

a,b,c,k=list(map(int,input().split()))
sum=0
if(a>=k):
    print(k)
    sys.exit()
else:
    sum=a
if(b>=k-a):
    print(a)
    sys.exit()
else:
    sum=sum-(k-a-b)
    print(sum)

Measured memory_bytes: 61920
# coding: utf-8
n, m = map(int, input().split())

ans = 0
# 最初のs使いきれるか
if 2 * n >= m:
    print(min(n, m // 2))
else:
    ans += n
    m -= 2 * n
    ans += m // 4
    print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
	
int main(){
	ll n;
	cin>>n;
	ll ar[n];
	for(int i=0;i<n;i++){
	 	cin>>ar[i];
	}
	 
	ll *dp = new ll[n+1]();
	dp[n] = ar[n-1];
	for(int i=n-1;i>0;i--){
	 	dp[i] = (dp[i+1]%mod + ar[i-1]%mod)%mod;
	}
	/*for(int i=1;i<=n;i++){
		cout<<dp[i]<<" ";
	}*/
	 
	ll sum = 0;
	
	for(int i=1;i<n;i++){
		ll curr = (ar[i-1]%mod*dp[i+1]%mod)%mod;
		sum = (sum%mod+curr%mod)%mod;	
	}
	cout<<sum%mod;		 
	 	 
	 return 0;
	}


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

int main() {
  int n;
  cin >> n;
  string s = "MARCH";
  long long c[5] = {0};
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    for (int j = 0; j < 5; j++) {
      if (t[0] == s[j]) {
        c[j]++;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += c[i]*c[j]*c[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

    while (1) {
        int N, M;
        cin >> N >> M;
        if (!N & !M) break;
        unordered_map<int, int> DV;
        for (int i = 1; i <= M; i++) {
            DV[i] = 0;
        }
        for (int i = 0; i < N; i++) {
            int d, v;
            cin >> d >> v;
            DV[d] = max(v, DV[d]);
        }
        int ans = 0;
        for (int i = 1; i <= M; i++) {
            ans += DV[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3132
#include <stdio.h>

int main(void) {
int a,b,c,x;

scanf( "%d %d %d" , &a, &b , &c );

 if(a > b ) {
x = a;
a = b;
b = x;

}

 if(b > c) {
 x = b;
b = c;
c = x;
} 
 if(a > b ) {
x = a;
a = b;
b = x;

}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 1816
n, y =  map(int, input().split())
 
res_a = -1
res_b = -1
res_c = -1
 
for i in range(n+1):
  for j in range(n+1):
      if 10000*i + 5000*j + 1000*(n-i-j) == y and i+j <= n:
        res_a, res_b, res_c = i, j, n-i-j
        break
        
print(res_a, res_b, res_c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int a[5],b,c,d,sum=0;
	string s;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
    }
	cin>>b;
    for(int i=0;i<5;i++)
    {
        for(int n=0;n<5;n++)
        {
            if(a[n]-a[i]>b)
            {
                cout<<":(";
                return 0;
            }
        }
    }
	cout<<"Yay!";
	return 0;
}
	

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

int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, 0, n) cin >> d[i];
    ll ans = 0;
    rep(i, 0, n-1){
        rep(j, i+1, n) ans += d[i] * d[j];
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii >
#define vll vector<ll >
#define cps CLOCKS_PER_SEC
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define print(s) cout<<#s<<" : ";for(auto i:(s))cout<<i<<" ";cout<<"\n";
#define slld(t) scanf("%lld",&(t))
#define sd(t) scanf("%d",&(t))
#define pd(t) printf("%d\n",(t))
#define plld(t) printf("%lld\n",(t))
#define endl "\n"
int A[1000000];
int main()
{
    int n,x,y;
    sd(n);
    sd(x);
    rep(i,0,n)
    sd(A[i]);
    ll ans = 0;
    for(int i = 0;i<n-1;i++)
    {
        if(A[i]+A[i+1] > x)
        {
            ll sub = A[i]+A[i+1]-x;
            A[i+1] -= min(A[i+1],(int)sub);
            ans += sub;
        }
    }
    plld(ans);
}

Measured memory_bytes: 640
a = [0]*1000001
a[1] = int(input())
def fun(n):
    if n%2:
        return 3*n + 1
    else:
        return int(n/2)
    
for i in range(2,1000001):
    a[i] = fun(a[i-1])
    if a[i] in a[:i]:
        print(i)
        break

Measured memory_bytes: 10868
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String s = scanner.nextLine();

        int x = 0;
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            switch (s.charAt(i)) {
                case 'I':
                    x++;
                    if (x > max) {
                        max = x;
                    }
                    break;
                case 'D':
                    x--;
                    break;
            }
        }
        System.out.println(max);
    }
}


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

int main() {
	int n;
	cin >> n;
	bool flag = false;
	for (int i = 0;i <= n;++i) {
		for (int j = 0;j <= n;++j) {
			int res = 4 * i + 7 * j;
			if (res == n) {
				flag = true;
			}
		}
	}
	if (flag == true)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,L = LI()
S = sorted([S() for _ in range(N)])
print(*S,sep='')


Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
const int mod = 1000000007;
const int INF = 1e12;
template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

double PI = acos(-1.0);
int x[110], y[110];
double p[210];

signed main(){
    int n;
    cin >> n;
    rep(i, 0, n){
        cin >> x[i] >> y[i];
    }
    rep(i, 0, n){
        int id = 0;
        rep(j, 0, n){
            if(i == j) continue;
            p[id++] = atan2(y[j] - y[i], x[j] - x[i]);
        }
        sort(p, p + id);
        rep(j, 0, id) p[j + id] = p[j] + 2 * PI;
        double res = 0.0;
        rep(j, 0, id){
            res = max(res, p[j] + PI - p[(j + id - 1)]);
        }
        printf("%.10f\n", res / (2.0 * PI));
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 2000
//---------------------

ll w,h;
string s[MAXN];
ll vl[MAXN][MAXN];
ll hl[MAXN][MAXN];

int main(){
	cin>>h>>w;
	memset(vl,0,sizeof(ll)*MAXN*MAXN);
	memset(hl,0,sizeof(ll)*MAXN*MAXN);
	REP(i,h) cin>>s[i];
	REP(i,h){
	  	ll lastid=0;
	  	ll num=0;
		REP(j,w){
			if(s[i][j]=='#'||j==w-1){
			  	if(j==w-1&&s[i][j]=='.') {num++;j++;}
			  	if(j!=lastid) {
			  		for(ll k=lastid;k<=j-1;k++){
			  			hl[i][k]=num;
			  		}
			  	}
			  	num=0;
				lastid=j+1;
				continue;
			}else{
				num++;
			}
		}
	}
	REP(j,w){
	  	ll lastid=0;
	  	ll num=0;
		REP(i,h){
			if(s[i][j]=='#'||i==h-1){
			  	if(i==h-1&&s[i][j]=='.') {num++;i++;}
			  	if(i!=lastid) {
			  		for(ll k=lastid;k<=i-1;k++){
			  			vl[k][j]=num;
			  		}
			  	}
			  	num=0;
				lastid=i+1;
				continue;
			}else{
				num++;
			}
		}
	}
	ll maxn=-1;
	REP(i,h){
		REP(j,w){
			maxn=max(maxn,vl[i][j]+hl[i][j]-1);
		}
	}
	/*
	REP(i,h){
		REP(j,w){
			cout<<vl[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
	REP(i,h){
		REP(j,w){
			cout<<hl[i][j];
		}
		cout<<endl;
	}*/
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 66816
#include<iostream>
#include <math.h>
using namespace std;

unsigned long long sub(int N, unsigned long long X) {
    if (N>0 && X<=1) {
        return 0;
    }
    if (N==0 && X>0) { 
        return 1;
    }
    if (N==0 && X==0) { 
        return 0;
    }
    unsigned long long len = pow(2, N+2) - 3;

    unsigned long long len_prev = pow(2, N+1) - 3;
    if (X==len) {
        return 2*sub(N-1, len_prev)+1;
    } else if (X<=len_prev+1) {
        return sub(N-1, X-1);
    } else if (X>len_prev+2) {
        return 1 + sub(N-1, len_prev) + sub(N-1, X-len_prev-2);
    } else {
        return 1 + sub(N-1, len_prev);
    }
}

int main() {
    int N;
    unsigned long long X;
    cin >> N >> X;
    unsigned long long ans = sub(N, X);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K,Q;
ll A[200010],B,C,D,X;
ll ans=INF;
ll F[200010];
string S,T,U;
int main(){
    cin>>K>>S;
    if(S.size()<=K)cout<<S;
    else cout<<S.substr(0,K)<<"...";
    

}


Measured memory_bytes: 3632
using System;

class Program
{
	static void Main(string[] args)
	{
		int i;

		int n = int.Parse(Console.ReadLine());
		Int64[] fk = new Int64[n+1];

		int tmpk;
		Int64 result = 0;

		for (i = 1; i <= n; i++)
		{
			tmpk = i;
			while(tmpk <= n)
            {
				fk[tmpk]++;
				tmpk += i;
            }
			result += (Int64)i * fk[i];
		}


		Console.WriteLine(result);

		return;
	}
}

Measured memory_bytes: 105656
N = int(input())
A = [int(x) for x in input().split()]
L = [0]*(10**5+1)
for i in range(N):
    L[A[i]] += 1
    L[A[i] + 1] += 1
    if A[i] != 0:
        L[A[i] - 1] += 1
print(max(L))


Measured memory_bytes: 13964
#include <cstdio>
#include <cstring>
#include <map> 
#include <vector>
#include <algorithm>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef long long ll;

const int N = 1e5 + 500;

vector < ll > q;
map < ll, ll > S;
ll sol[N];
int n, Q;

int main(){
	scanf("%d%d", &n, &Q);
	q.PB(n);
	for(int i = 0;i < Q;i++){
		ll x; scanf("%lld", &x);
		while((int)q.size() > 0 && q.back() >= x)
			q.pop_back();
		q.PB(x);
	}
	Q = (int)q.size();
	S[q[Q - 1]] = 1;
	for(int i = Q - 2;i >= 0;i--){
		while(S.rbegin() -> X > q[i]){
			S[q[i]] += S.rbegin() -> Y * (S.rbegin() -> X / q[i]);
			S[S.rbegin() -> X % q[i]] += S.rbegin() -> Y;
			S.erase(--S.end()); 
		}
	}
	for(int i = n;i >= 1;i--){
		sol[i] = sol[i + 1] + S[i];
	}
	for(int i = 1;i <= n;i++)
		printf("%lld\n", sol[i]);
	return 0;
}

Measured memory_bytes: 9588
x = list(map(int,input().split()))

for i in range(2,0,-1):
    k = 0
    while k < i:
        if x[k] > x[k+1]:
            x[k],x[k+1] = x[k+1],x[k]
        k += 1;


print(x[0],x[1],x[2])


Measured memory_bytes: 5600
import sys
input = sys.stdin.buffer.readline


def main():
    N, M, L = map(int, input().split())
    dist = [[float('inf') for _ in range(N+1)] for _ in range(N+1)]
    ans = [[float('inf') for _ in range(N+1)] for _ in range(N+1)]
    for i in range(1, N+1):
        dist[i][i] = 0
    for _ in range(M):
        a, b, c = map(int, input().split())
        if c <= L:
            dist[a][b] = c
            dist[b][a] = c

    for k in range(1, N+1):
        for j in range(1, N+1):
            for i in range(1, N+1):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    for i in range(1, N+1):
        for j in range(1, N+1):
            if dist[i][j] <= L:
                ans[i][j] = 1
    for k in range(1, N+1):
        for j in range(1, N+1):
            for i in range(1, N+1):
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j])

    Q = int(input())
    for _ in range(Q):
        s, t = map(int, input().split())
        if ans[s][t] < 10**10:
            print(ans[s][t]-1)
        else:
            print(-1)


if __name__ == '__main__':
    main()


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, std::string S){
    vector<i64> a(N + 1), b(N + 1), c(N + 1);
    rep(i, N){
        a[i + 1] = a[i];
        b[i + 1] = b[i];
        c[i + 1] = c[i];
        if(S[i] == 'R') a[i + 1] = a[i] + 1;
        if(S[i] == 'G') b[i + 1] = b[i] + 1;
        if(S[i] == 'B') c[i + 1] = c[i] + 1;
    }
    i64 ans = 0;
    rep(i, N - 2){
        rep(j, i + 1, N - 1){
            if(S[i] == 'R' && S[j] == 'G' || S[j] == 'R' && S[i] == 'G'){
                ans += c[N] - c[j + 1];
                if(2 * j - i < N && S[2 * j - i] == 'B') ans--;
            }
            if(S[i] == 'R' && S[j] == 'B' || S[j] == 'R' && S[i] == 'B'){
                ans += b[N] - b[j + 1];
                if(2 * j - i < N && S[2 * j - i] == 'G') ans--;
            }
            if(S[i] == 'B' && S[j] == 'G' || S[j] == 'B' && S[i] == 'G'){
                ans += a[N] - a[j + 1];
                if(2 * j - i < N && S[2 * j - i] == 'R') ans--;
            }
        }
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

int main(){
    int n, x;
    
    
    while(1){
        int count =0;
        cin >> n >> x;
        
        if(n==0 && x==0) break;
        
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k == x) count++;
                }
            }
        }
        cout << count << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3080
line = input().split()
n = int(line[0])
m = int(line[1])

# 偶数と偶数の方法の数
eeCount = n * (n - 1) / 2

# 奇数と奇数の方法の数
ooCount = m * (m - 1) / 2

print(int(eeCount + ooCount))

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }
    sort(all(p));
    int res = 0;
    rep(i, k){
        res += p[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 3596
if __name__ == "__main__":
    n, k, q = map(int, input().split())
    a = list()

    point = [0] * n

    for i in range(q):
        tmp = int(input()) - 1
        point[tmp] += 1

    for i in range(n):
        if point[i] + k - q <= 0:
            print('No')
        else:
            print('Yes')


Measured memory_bytes: 4680
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Ubiquity
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

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

  int e10 = powmod(10, n), e9 = MOD - powmod(9, n), e8 = powmod(8, n);
  printf("%lld\n", ((ll)e10 + e9 * 2 + e8) % MOD);
  return 0;
}


Measured memory_bytes: 3772
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	for c := 1; c <= 3; c++ {
		if a*b*c%2 == 1 {
			println("Yes")
			return
		}
	}
	println("No")
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//239///F.Sugoroku
	int n;
	cin>>n;
	vi b(n-1);
	ll sum = 0;
	REP(i,0,n-2)cin>>b[i];
	REP(i,1,n-2)sum+=min(b[i],b[i-1]);
	sum+=b[0];
	sum+=b[n-2];
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main(){
    ll x; cin >> x;

    ll h500 = x/500;
    x %= 500;

    ll h5 = x/5;

    cout << h500*1000 + h5*5 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
S = list(input())

if N % 2 == 0:
	T = S[:int(len(S)/2)]
	T_end = S[int(len(S)/2):]

	for i in range(len(T)):
		if T[i] != T_end[i]:
			print('No')
			sys.exit()

	print('Yes')
	sys.exit()
else:
	print('No')


Measured memory_bytes: 3060