akhauriyash/Code-Regression huggingface dataset:
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p
N,K = map(int,input().split())
A = [1 for _ in range(N+1)]
for i in range(2,N+1):
    A[i] = (i*A[i-1])%p
B = [1 for _ in range(N+1)]
B[N] = pow(A[N],p-2)
for i in range(N-1,1,-1):
    B[i] = ((i+1)*B[i+1])%p
for i in range(1,K+1):
    if N-K-i+1>=0:
        a = (A[K-1]*B[i-1])%p
        a = (a*B[K-i])%p
        a = (a*A[N-K+1])%p
        a = (a*B[i])%p
        a = (a*B[N-K-i+1])%p
    else:
        a = 0
    print(a)

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

int main(){
    string s, t; cin >> s >> t;
    int Mi = 0x3f3f3f3f;
    for (int i = 0; i < s.length()-t.length()+1; i++){
        int sum = 0;
        for (int j = 0; j < t.length(); j++){
            if (s[i+j] != t[j]) sum++;
        }
        Mi = min(Mi, sum);
    }
    cout << Mi << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD=1e9+7;

ll tim(ll a, ll b){
	return (a*b)%MOD;
}
ll adm(ll a, ll b){
	return (a+b)%MOD;
}
ll mim(ll a, ll b){
	return (a-b+MOD)%MOD;
}

ll pwm(ll a, ll k){
	if(k==0)return 1;
	ll p=pwm(a, k/2);
	if(k%2==0) return (p*p)%MOD;
	if(k%2==1) return (a*((p*p)%MOD))%MOD;
}

int main(){
	int N,C;
	cin>>N>>C;
	ll A[401], B[401];
	rep1(i,N)cin>>A[i];
	rep1(i,N)cin>>B[i];
	
	//sm[i][j]は1からiまでのj乗和
	ll sm[401][401];
	rep(j,401)sm[0][j]=0;
  	rep1(i,400)sm[i][0]=i;
	rep1(j,400)rep1(i,400){
		sm[i][j]=adm(sm[i-1][j], pwm(i,j));
	}
	
	ll dp[401][401];
	rep1(i,N)rep(j,C+1)dp[i][j]=0;
	rep(j,C+1) dp[1][j]=mim(sm[B[1]][j], sm[A[1]-1][j]);
	for(int i=2; i<=N; i++)rep(j,C+1)rep(k,j+1){
		ll r=mim(sm[B[i]][k], sm[A[i]-1][k]);
		dp[i][j]=adm(dp[i][j], tim(dp[i-1][j-k], r));
	}

	cout<<dp[N][C]<<endl;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int box[3],t;
    cin>>box[0]>>box[1]>>box[2];
    t=box[1];
    box[1]=box[0];
    box[0]=box[2];
    box[2]=t;
    cout<<box[0]<<" "<<box[1]<<" "<<box[2];
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
using namespace std;
int main(){
    long double a,b,c;
    cin >> a >> b >>c;
    long double eps = 1.0E-14;

     long double x=sqrt(a);
     long double y=sqrt(b);
     long double z=sqrt(c);

    if(x+y+eps<z) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ans = 1;
  for(int i=1;i<N;++i){
    if(s[i]!=s[i-1]){
      ans += 1;
    }
  }
  cout << ans << endl;
}


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

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A.at(i);
    }
    ll tmp = 0;
    ll mod = 1000000007;
    ll sum = accumulate(A.begin(),A.end(),0LL);
    ll ans = 0;
    for(ll i = 0;i<N-1;i++){
        sum = sum-A.at(i);
        tmp = sum%mod;
        tmp = tmp*A.at(i);
        tmp = tmp%mod;
        ans = ans + tmp;
        ans %=mod;
    }
    // for(ll i=0;i<N-1;i++){
    //     for(ll j=i+1;j<N;j++){
    //         ans += A.at(i)*A.at(j);
    //         ans=ans%mod;
    //     }
    // }
    cout<<ans;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9
#define LLINF 11e16
 
using namespace std;
 
typedef long long ll;

int main(){
	int a, b;
	cin >> a >> b;
	
	int p, q, r;
	
	p = a + b;
	q = a - b;
	r = a * b;
	
	int ans;
	ans = max(p, max(q, r));
	
	cout << ans << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(){
	float data;//標高の高さデータ
	float max,min,div;//
	max=LONG_MIN;
	min=LONG_MAX;
	while(~scanf("%f",&data)){
		if(max<data) max=data;
		if(min>data) min=data;
	}
	div=max-min;
	printf("%.1f\n",div);
	return 0;
}

Measured memory_bytes: 648
import random
import time

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]

def decr(tl,cl):
    dec=0
    for i in range(26):
        last=[a for a, x in enumerate(tl) if x==i+1]
        if last==list():
            dec+=(d*(d+1)/2)*cl[i]
        else:
            for v in range(len(last)):
                if v!=len(last)-1:    
                    dec+=cl[i]*(last[v+1]-last[v]-1)*(last[v+1]-last[v])/2
                else:
                    dec+=cl[i]*(d-last[v]-1)*(d-last[v])/2
            dec+=cl[i]*(last[0])*(last[0]+1)/2
    return(int(dec))

oldscore=sat
oldans=oldscore-decr(tl,cl)
oldtl=[int(x) for x in tl]
t2=time.time()
while t2-t1<1.85:
    if round(t2)/2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        tl[d2-1]=q1
        tl[d1-1]=q2
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        tl[da-1]=q
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
    r=0
    if newans<oldans:
        if 2.7**((newans-oldans)/(1.85-(t2-t1)))<random.random():
            r=1
    if r==1:
        tl=[int(x) for x in oldtl]
    else:
        oldans=newans
        oldtl=[int(x) for x in tl]
        oldscore=newscore
    t2=time.time()
for i in range(d):
    print(tl[i])

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    cout << (n-1) / max(h, w) + 1 << endl;
    return 0;
}





Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


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

  string s,t;
  cin >> s >> t;

  /*
  // s1の(i-1)文字目までの文字列に1文字追加する場合
  dp[i][j] = dp[i-1][j] + 1;
  //s2のj文字目を削除する場合
  dp[i][j] = dp[i][j-1] + 1;
  // s1のi文字目とs2のj文字目が同じ文字になるように置換する場合
  dp[i][j] = dp[i-1][j-1] + cost;
  // -> i文字目とj文字目が等しければコストはかからない
  cost = (s[i-1] == t[j-1]) ? 0 : 1;
  */

  int n = s.size() ,m = t.size();
  int dp[s.size()+1][t.size()+1];
  rep(i,n+1)    dp[i][0] = i;
  rep(i,m+1)  dp[0][i] = i;

  FOR(i, 1, n+1) FOR(j, 1, m+1){
    int cost = (s[i-1] == t[j-1]) ? 0 : 1;
    dp[i][j] = min(min(dp[i-1][j]+1, dp[i][j-1]+1), dp[i-1][j-1] + cost);
  }
  cout << dp[n][m] << endl;

  return 0;
}



Measured memory_bytes: 7144
#include <iostream>
#include <vector>
#include <algorithm>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  
  int N, ans = 0;

  cin >> N;

  vector<int> p(N);

  REP(i,N){
    cin >> p[i];
  }

  VSORT(p);

  REP(i,N-1){
    ans += p[i];
  }

  ans += p[N-1]/2;

  cout << ans << endl;

  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  int h[n], g[n];
  for(int i = 0;i<n;++i){
    cin >> h[i];
    g[i] = 1;
  }
  int a,b;
  for(int i = 0;i<m;++i){
    cin >> a >> b;
    a--;
    b--;
    if(h[a] > h[b]){
      if(g[b] == 1) g[b] = 0;
    }else if(h[a] < h[b]){
      if(g[a] == 1) g[a] = 0;
    }else{
      g[a] = 0;
      g[b] = 0;
    }
  }
  int c = 0;
  for(int i = 0;i<n;++i){
    if(g[i]==1) c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 4428
S=list(input())
if len(S)%2==0:
    A=['0','1']*(len(S)//2)
    B=['1','0']*(len(S)//2)
else:
    A=['0','1']*(len(S)//2)+['0']
    B=['1','0']*(len(S)//2)+['1']

a,b=0,0
for i in range(len(S)):
    if A[i]!=S[i]:
        a+=1
        continue
for k in range(len(S)):
    if B[k]!=S[k]:
        b+=1
        continue
print(min(a,b))

Measured memory_bytes: 6172
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n, k;
int cnt;
int num[100005];

void init() {
	scanf("%d%d", &n, &k);
	for(register int i = 1; i <= n; i++) {
		scanf("%d", &num[i]);
	}
	return ;
}

void solve() {
	for(register int i = 1; i <= n; i++) {
		if(num[i] >= k) ++cnt;
	}
	printf("%d", cnt);
	return ;
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n;
	cin>>n;
	cout<<n*n*n<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>

using namespace std;

struct P {
    char name[100];
    int t;
};

class Queue {
public:
    Queue(int n) : len_(n) {
        queue_ = new P[len_];
        head_ = 0;
        tail_ = 0;
    };

    ~Queue() {
        delete queue_;
    };

    bool isEmpty() {
        return tail_ <= head_;
    }

    void enqueue(P p) {
        queue_[tail_ % len_] = p;
        tail_++;
    }

    P dequeue() {
        P p = queue_[head_ % len_];
        head_++;
        return p;
    }

private:
    int len_;
    P* queue_;
    int head_;
    int tail_;
};

int main() {
    int n;
    int q;
    cin >> n >> q;
    Queue queue = Queue(n);
    for (int i = 0; i < n; ++i) {
        P p;
        cin >> p.name >> p.t;
        queue.enqueue(p);
    }
    int elaps = 0;
    while (!queue.isEmpty()) {
        P p = queue.dequeue();
        if (p.t <= q) {
            elaps += p.t;
            cout << p.name << " " << elaps << endl;
        } else {
            elaps += q;
            p.t -= q;
            queue.enqueue(p);
        }
    }
    return 0;
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int A,B,Q;
  cin >> A >> B >> Q;
  A+=2;
  B+=2;
  vector<ll> S(A);
  vector<ll> T(B);
  S.at(0)=-1e15;
  T.at(0)=-1e15;
  REP(i,1,A-1)  cin >> S.at(i);
  REP(i,1,B-1)  cin >> T.at(i);
  S.at(A-1)=1e15;
  T.at(B-1)=1e15;

  rep(_,Q){
    ll x;
    cin >> x;
    ll sl=*(lower_bound(all(S),x)-1);
    ll sr=*(lower_bound(all(S),x));
    ll tl=*(lower_bound(all(T),x)-1);
    ll tr=*(lower_bound(all(T),x));

    sl=x-sl;
    sr=sr-x;
    tl=x-tl;
    tr=tr-x;

    ll ans=1e18;
    chmin(ans,max(sl,tl));
    chmin(ans,max(sr,tr));
    chmin(ans,2*min(sl,tr) + max(sl,tr));
    chmin(ans,2*min(sr,tl) + max(sr,tl));
    cout << ans << endl;
  }

  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int a[26] = {0};
    for(int i = 0 ;  i < (int)s.length() ; i++)
    a[s[i] - 'a'] = 1;
    for(int i = 0 ; i < 26 ; i++)
    {
        if(!a[i])
        {
            cout << (char)(i + 'a');
            return 0;
        }
        
    }
    cout << "None";
    return 0;
    
}

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

int main()
{
  int a, b;
  char op;

  while(cin >> a >> op >> b){
    if(op == '?') break;

    if(op == '+') cout << a + b << endl;
    if(op == '-') cout << a - b << endl;
    if(op == '*') cout << a * b << endl;
    if(op == '/') cout << a / b << endl;

  }

  return 0;

}

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

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if((x-r>=0)&&(y-r>=0)&&(x+r<=w)&&(y+r<=h))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3112
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    v = LI()
    acnt = collections.Counter(v[::2])
    bcnt = collections.Counter(v[1::2])
    acnt = list(acnt.items())
    bcnt = list(bcnt.items())
    acnt.sort(key=lambda x: x[1], reverse=True)
    bcnt.sort(key=lambda x: x[1], reverse=True)

    acnt.append((-1,0))
    bcnt.append((-1,0))

    ans = 0

    if acnt[0][0] != bcnt[0][0]:
        ans = n - acnt[0][1] - bcnt[0][1]
    else:
        ans = min(n-acnt[0][1]-bcnt[1][1], n-acnt[1][1]-bcnt[0][1])

    print(ans)

main()


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

#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmin(x,y) x = min(x,y)


int main() {
  int A[3][3];
  rep(i,3)rep(j,3) {
    cin >> A[i][j];
  }
  int N;
  cin >> N;

  int b[N];
  int bingo[3][3];
  rep(i,3)rep(j,3) {
    bingo[i][j] = 0;
  }

  rep(i,N) {
    cin >> b[i];
    rep(j,3)rep(k,3) {
      if (A[j][k] == b[i]) {
        bingo[j][k] = 1;
        break;
      }
    }
  }

  bool flag[8];
  rep(i,8) {
    flag[i] = true;
  }
  rep(i,3) {
    if (bingo[i][0] == 0) flag[0] = false;
    if (bingo[i][1] == 0) flag[1] = false;
    if (bingo[i][2] == 0) flag[2] = false;
    if (bingo[0][i] == 0) flag[3] = false;
    if (bingo[1][i] == 0) flag[4] = false;
    if (bingo[2][i] == 0) flag[5] = false;
    if (bingo[i][i] == 0) flag[6] = false;
    if (bingo[i][2-i] == 0) flag[7] = false;
  }

  if (flag[0] || flag[1] || flag[2] || flag[3] || flag[4] || flag[5] || flag[6] || flag[7]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



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

using namespace std;
typedef long long ll;


ll A,B;


ll equlid(ll a,ll b){
    while (a%b != 0) {
        ll c = a%b;
        a = b;
        b = c;
    }
    return b;
}


int main()
{
    cin >> A >> B;
    vector<ll> a;
    for (ll i = 1; i*i <= A; i++) {
        if(A%i==0){
            if(B%i == 0) a.push_back(i);
            if(A/i != i && B%(A/i) == 0) a.push_back(A/i);
            
        }
    }
    
    sort(all(a));
    
    int ans = 0;
    ll b = 1;
    
    for (int i = 0; i < int(a.size()); i++) if(equlid(b,a[i]) == 1) b = b*a[i], ans++;
    
    
    cout << ans << endl;
    
    
    
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
long long  a[51000000];
long long  n,a1,b1;
long  panduan(long long  zhi)
{
    long long  t=b1*zhi;
    long long  add=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]-t>0)
        {
            if((a[i]-t)%(a1-b1)==0)
                add+=(a[i]-t)/(a1-b1);
            else
                add+=(a[i]-t)/(a1-b1)+1;
        }
    }
    //cout<<zhi<<"_"<<add<<endl;
    return add<=zhi;
}
int  main()
{
    cin>>n>>a1>>b1;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    long long  kaishi=0,jieshu=1e9;
    long long  mid;
    //cout<<panduan(3)<<"_"<<endl;
    int t;
    while(kaishi<jieshu-1)
    {
        //cout<<kaishi<<"_"<<jieshu<<endl;
        mid=(jieshu+kaishi)>>1;
        if(panduan(mid))
        {
            jieshu=mid;
            t=mid;
        }
        else
            kaishi=mid;
    }
    cout<<jieshu<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {

	long long X;
	long long Y = 0;
	cin >> X;
	if (X < 5)
		cout << 0 << endl;
	else {
		Y += (X / 500) * 1000 + (X % 500) / 5 * 5;
		cout << Y << endl;
	}
  
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
// #define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
#define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{ 
    int ans[10001] = {};
    repp(i,1,100)
        repp(j,1,100)
            repp(k,1,100)
            {
                int lol = i*i+i*j+i*k+j*j+j*k+k*k;
                if(lol<=10000)
                    ans[lol]++;
            }
    int n;
    cin >> n;
    repp(i,1,n+1)
        cout << ans[i] << endl;

}

Measured memory_bytes: 3728
import scala.collection.mutable

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val hashMap = mutable.Map[Int, Int]()
  for (_ <- 2 to N) {
    val a = sc.nextInt()
    val count = hashMap.getOrElse(a, 0)
    hashMap.update(a, count + 1)
  }
  1.to(N).foreach(i => println(hashMap.getOrElse(i, 0)))
}


Measured memory_bytes: 77028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k;
    cin >> n >> k;
    vi v(200010,0);
    rep(i,n){
        int a;
        cin >> a;
        v[a]++;
    }
    sort(v.begin(),v.end());
    auto itr = upper_bound(v.begin(),v.end(),0);
    ll ans = 0;
    int t = v.end() - itr;
    //cout << t << endl;
    while(t>k){
        ans += *itr;
        itr++;
        t--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Dic = {x:0 for x in set(A)}
    if len(Dic) <= k:
        print(0)
    else:
        for i in A:
            Dic[i] += 1
        Dicsort = sorted(Dic.items(), key=lambda x: x[1])

        cnt = 0
        for j in range(len(Dic) - k):
            cnt += Dicsort[j][1]

        print(cnt)
resolve()

Measured memory_bytes: 109384
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
// string x(w.size(),'1');
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007

ll ar[MAX],ans[MAX];

int main()
{
 //O_O ;
   ll n;
   cin>>n;
   for(ll i=1;i<=n;i++)
    cin>>ar[i];
   ans[n]=0,
   ans[n-1]=abs(ar[n-1]-ar[n]);
   for(ll i=n-2;i>=1;i--)
   {
       ans[i]=min((abs(ar[i]-ar[i+1])+ans[i+1]),(abs(ar[i]-ar[i+2])+ans[i+2]));
      // cout<<<<ss<<i<<nn;
       // cout<<(abs(ar[i]-ar[i+2])+ans[i+2])<<ss<<i<<nn;

   }
  // for(ll i=1;i<=n;i++)
   // cout<<ans[i]<<ss;cout<<nn;
   cout<<ans[1]<<nn;

    return 0;
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
#define MAX 100001
#define EXP 1000000007
using namespace std;
int dp[27];
char s[MAX],t[MAX];
int main(void)
{
	int n;
	cin>>n;
	cin>>s>>t;
	fill(dp,dp+26,0);
	dp[s[0]-'a']++;
	for(int i=1;i<n-1;i++){
		dp[s[i]-'a']+=dp[t[i]-'a'];
		dp[s[i]-'a']%=EXP;
	}
	cout<<dp[t[n-1]-'a']<<endl;
	return 0;
}
		
		


Measured memory_bytes: 3332
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


long long lefttoright(const string &s){
	long long a=0,b=0;
	int i;
	char op;
	for(i=0;i<s.size()&&s[i]!='+'&&s[i]!='*';i++){
		a*=10;
		a+=s[i]-'0';
	}
	if(i==s.size())return a;
	op=s[i++];
	for(;i<s.size();i++){
		if(s[i]=='+'||s[i]=='*'){
			if(op=='+'){
				a+=b;
			}else{
				a*=b;
			}
			op=s[i];
			b=0;
		}else{
			b*=10;
			b+=s[i]-'0';
		}
	}
	if(op=='+'){
		a+=b;
	}else{
		a*=b;
	}
	return a;
}


long long mulfirst(const string &s){
	long long a=0;
	int i,j=-1;
	for(i=0;i<s.size();i++){
		if(s[i]=='+'){
			a+=lefttoright(s.substr(j+1,i-j-1));
			j=i;
		}
	}
	a+=lefttoright(s.substr(j+1,s.size()-j-1));
	return a;
}



int main(){
	string expr;
	int v;
	cin>>expr>>v;
	char ans[]="IMLU";
	cout<<ans[(v==mulfirst(expr))+2*(v==lefttoright(expr))]<<endl;
	return 0;
}

Measured memory_bytes: 1200
#!/usr/bin/env python3
import sys


def solve(N: int):
    dig = int([c for c in str(N)][-1])
    if dig in [2,4,5,7,9]:
        print('hon')
    elif dig in [0, 1, 6, 8]:
        print('pon')
    else:
        print('bon')
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int main() {
	int n,l,r,k=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l>>r;
		k+=r-l+1;
		}
		cout<<k<<endl;
  return 0;
  }

Measured memory_bytes: 256
n = gets.to_i
words = []
n.times do |i|
 words.push(gets.chomp)
end

ans = "Yes"
if words.length != words.uniq.length
  ans = "No"
else
  stackw = words.shift
  while words.length > 0
    next_w = words.shift
    if stackw[-1] != next_w[0]
      ans = "No"
      break
    else
      stackw = next_w
    end
  end
end

puts(ans)

Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 160000;
const int K = 20000;
pair < pair < int, int >, pair < int, int > > a[N];
int t[N], d[N], q[N];
double p;
int sum (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += t[r];
	return result;
}

void inc (int i, int delta)
{
	for (; i < N; i = (i | (i+1)))
		t[i] += delta;
}
bool cmp(pair < pair < int, int >, pair < int, int > > x, pair < pair < int, int >, pair < int, int > > y){
    double v1 = (x.S.F - p * x.F.F) * y.F.S;
    double v2 = (y.S.F - p * y.F.F) * x.F.S;
    return (v1 > v2);
}
bool cmp2(int i, int j){
    if (a[i].F.F < 0 && a[j].F.F > 0) return 1;
    if (a[i].F.F > 0 && a[j].F.F < 0) return 0;
    if (a[i].F.F > 0 && a[j].F.F > 0) return a[i].F.F * a[i].F.F * (a[j].F.F * a[j].F.F + a[j].F.S * a[j].F.S) < a[j].F.F * a[j].F.F * (a[i].F.F * a[i].F.F + a[i].F.S * a[i].F.S);
    if (a[i].F.F < 0 && a[j].F.F < 0) return a[i].F.F * a[i].F.F * (a[j].F.F * a[j].F.F + a[j].F.S * a[j].F.S) > a[j].F.F * a[j].F.F * (a[i].F.F * a[i].F.F + a[i].F.S * a[i].F.S);
}
double solve(int n){
    double l = -1e14;
    double r = 1e14;
    for (int i = 1; i <= n; i++){
        q[i] = i;
    }
    sort(q + 1, q + n + 1, cmp2);
    for (int i = 1; i <= n; i++) d[q[i]] = i;
    while(r - l > 1e-13){
        double mid = (r + l) / 2;
        p = mid;
        sort(a + 1, a + n + 1, cmp);;
        int c = 0;
        for (int i = 0; i < N; i++) t[i] = 0;
        for (int i = 1; i <= n; i++){
            c += sum(d[a[i].S .S]);
            inc(d[a[i].S.S], 1);
        }
        c = n * (n - 1) / 2 - c;
        if (4 * c > n * (n - 1)) l = mid; else r = mid;
    }
    return l;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i].F.F >> a[i].F.S >> a[i].S.F;
        if (a[i].F.S < 0){
            a[i].F.F = -a[i].F.F;
            a[i].F.S = -a[i].F.S;
            a[i].S.F = -a[i].S.F;
        }
        a[i].S.S = i;
    }
    double ans1 = solve(n);
    for (int i = 1; i <= n; i++){
        swap(a[i].F.F, a[i].F.S);
        if (a[i].F.S < 0){
            a[i].F.F = -a[i].F.F;
            a[i].F.S = -a[i].F.S;
            a[i].S.F = -a[i].S.F;
        }
        a[i].S.S = i;
    }
    double ans2 = solve(n);
    cout << fixed << setprecision(20) << ans1 << " " << ans2;
}


Measured memory_bytes: 4992
H, W, N, y, x = (gets+gets).split.map(&:to_i)
S, T = *$<
R, ST = Hash.new(0), {?L=>?R, ?R=>?L, ?U=>?D, ?D=>?U}
N.times{|i|
	R[S[i]] += 1
	if x-R[?L] < 1 or W < x+R[?R] or y-R[?U] < 1 or H < y+R[?D]
		puts 'NO'
		exit
	end
	R[ST[T[i]]] -= 1
	case ST[T[i]]
	when ?L
		R[?L] += 1 if W < x-R[?L]
	when ?R
		R[?R] += 1 if x+R[?R] < 1
	when ?U
		R[?U] += 1 if H < y-R[?U]
	when ?D
		R[?D] += 1 if y+R[?D] < 1
	end
}
puts 'YES'


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

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i].first;
    A[i].second=i;
  }
  sort(A.begin(), A.end());
  for(int i=0; i<N; i++) cout << A[i].second+1 << ' ';
  cout << endl;
}

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

int main() {
  int a,b,c;
  double x;
  
  cin >> a >> b;
  x = (a+b)*0.5;
  c = (a+b)/2 + ((a+b)/2 - x !=0);
  
  cout << c << endl;
  
  
}

Measured memory_bytes: 3616
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
        String n =s.next();
       	int p = (int)n.charAt(0);
       	p++;
       	System.out.println((char)p);
       	
    }	
}





        
    

      
 

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

int mod = 1'000'003;

long long modpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2 == 0) return modpow(x, y/2) * modpow(x, y/2) % mod;
    return x * modpow(x, y-1) % mod;
}

int main(){

    vector<long long> inv(mod, 0);
    inv[1] = 1;
    for (int i = 2; i < mod; i++){
        inv[i] = (mod - (mod/i)) * inv[mod % i] % mod;
    }

    vector<long long> fac(mod, 1);
    long long pro = 1;
    for (int i = 1; i < mod; i++){
        pro *= i;
        pro %= mod;
        fac[i] = pro;
    }

    int q;
    cin >> q;
    int x, d, n;
    for (int i = 0; i < q; i++){
        cin >> x >> d >> n;
        if (d == 0){
            cout << modpow(x, n) << endl;
            continue;
        }
        long long y = x * inv[d] % mod;
        if (y <= 0 || (y + n - 1 >= mod)) cout << 0 << endl;
        else{
            cout << (modpow(d, n) * fac[y + n - 1] % mod) * modpow(fac[y - 1], mod - 2) % mod << endl;
        }

    }
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n;cin >> n;
  string s;cin >> s;

  int cl = 0, cr = 0;
  string t = s;
  int i = 0;
  int li = -1;
  while(i < t.size()) {
    if(li < 0 && t[i] == ')') i++;
    else if (li < 0 && t[i] == '(') {
      li = i;
      i++;
    } else if (li >= 0 && t[i] == ')') {
      t.erase(i, 1);
      t.erase(li, 1);
      li = -1;
      i = 0;
    } else {
      i++;
    }
  }
  REP(i, t.size()) {
    if(t[i] == ')') cl++;
    else cr++;
  }
  REP(i, cl) cout << "(";
  cout << s;
  REP(i, cr) cout << ")";
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define endl "\n"
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define lli long long int
#define ll long long
#define f first
#define s second
#define MOD 1000000007

vector<int> arr[200005];
bool vis[200005]={ false };
int c=0;

void dfs(int node)
{
    c++;
    vis[node]=1;
    for (int child: arr[node])
    {
        if( !vis[child] )
        {
            dfs(child);
        }
    }
}

int main ()
{
    int n,e,x,y,ans=0;
    cin>>n>>e;
    while(e--)
    {
        cin>>x>>y;
        arr[x].push_back(y);
        arr[y].push_back(x);
    }

    for (int i=1;i<=n;i++)
    {
        c=0;
        if( !vis[i])
        {
            dfs(i);
        }
        ans =max(ans,c);
    }
    cout<<ans<<endl;
    return 0;
}
/*int ans=INT_MAX;
    string s,t;
    cin >> s >>t;
    int pos=s.find(t);
    if(pos==-1) {
        int i=0;
        while(i<s.size()) {
            while (s[i] != t[0] && i < s.size()) {
                i++;
            }
            if (i + 1 == s.size()) cout << min(ans, (int) t.size()) << endl;
            else {
                int j = 0, st = i;
                while (s[i] == t[j] && j < t.size())
                    i++, j++;
                ans = min(ans, (int) t.size() - (j - st));
            }
        }
    }
    else cout<<0<<endl;*/

Measured memory_bytes: 20956
#include <bits/stdc++.h>
using namespace std;
#define oo 2000000000
#define mod 998244353 
const int N = 200010 , K = 5010;
int n , arr[N] ;
long long mx[3] , dp[K * K];

int a[2] , b[2] , c[2];

int main(){
    scanf("%d",&n);
    for(int i = 0 ;i < 3;i++){
        scanf("%d%d%d",&a[i] , &b[i], &c[i]);
    }
    mx[0] = n;
    int tmp , nxt;
    long long cur , cur2 , cur3;
    for(int i = 0 ;i < 2;i++){
        tmp = (i & 1);
        nxt = (tmp ^ 1);
        dp[0] = 0;
        for(int j = 1;(long long)j <= mx[i];j++){
            dp[j] = dp[j - 1] + 1;
            if(j >= a[tmp]) dp[j] = max(dp[j] , a[nxt] + dp[j - a[tmp]]);
            if(j >= b[tmp]) dp[j] = max(dp[j] , b[nxt] + dp[j - b[tmp]]);
            if(j >= c[tmp]) dp[j] = max(dp[j] , c[nxt] + dp[j - c[tmp]]);
        }
        mx[i + 1] = dp[mx[i]];
    }
    cout << mx[2] << endl;
    return 0;
}

Measured memory_bytes: 196864
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k; cin >> k;
  string ans = "";
  rep(i, k) ans += "ACL";
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fio ios_base::sync_with_stdio(false)
using namespace std;
int main(){
    ll  x;
    cin>>x;
    ll k=360;
   int steps=0;
    while(1){
          if(k%x==0)
          break;
          k+=360;
    }
     cout<<k/x;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
map<ll,ll> p;
int main(){
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		p[a[i]]++;
	}
	for(auto x:p){
		ans+=(x.second*(x.second-1))/2;
	}
	ll sum=ans;
	for(ll i=1;i<=n;i++){
		ll x=p[a[i]];
		ans-=(x*(x-1))/2-((x-1)*(x-2))/2;
		cout<<ans<<endl;
		ans=sum;
	}
}

Measured memory_bytes: 12672
#include <stdio.h>

typedef unsigned long	us;

us max(us a, us b)
{
	if(a > b)
		return a;
	else
		return b;
}

us min(us a, us b)
{
	if(a < b)
		return a;
	else
		return b;
}

int main(void)
{
	us high, wide;
	us s_max = 0;
	us s_min = ~0;
	us ans = ~0;
	us i;
	
	
	scanf("%lu %lu", &high, &wide);
	
	for(i=1; i<high; i++){
		us a, b, c;
		us h = (high-i)/2;
		us w = wide/2;
		
		a = i*wide;
		b = (high-i)*w;
		c = (high-i)*(wide-w);
		s_max = max(a, max(b, c));
		s_min = min(a, min(b, c));
		
		ans = min(ans, s_max-s_min);
		
		b = h*wide;
		c = ((high-i)-h)*wide;
		s_max = max(a, max(b, c));
		s_min = min(a, min(b, c));
		
		ans = min(ans, s_max-s_min);
		
		//printf("high:%d max:%d min:%d\n", i, s_max, s_min);
		//printf("high:%d a:%d b:%d c:%d\n", i, a, b, c);
	}
	for(i=1; i<wide; i++){
		us a, b, c;
		us h = high/2;
		us w = (wide-i)/2;
		
		a = i*high;
		b = (wide-i)*h;
		c = (wide-i)*(high-h);
		s_max = max(a, max(b, c));
		s_min = min(a, min(b, c));
		
		ans = min(ans, s_max-s_min);
		
		b = w*high;
		c = ((wide-i)-w)*high;
		s_max = max(a, max(b, c));
		s_min = min(a, min(b, c));
		
		ans = min(ans, s_max-s_min);
		
		//printf("wide:%d max:%d min:%d\n", i, s_max, s_min);
		//printf("wide:%d a:%d b:%d c:%d\n", i, a, b, c);
	}
	
	printf("%lu\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void dfs(vector<vector<int> >& B, int tmp, int len, vector<bool>& vis, vector<bool>& vis2, bool& flag, vector<int>& depth) {
  if(flag) return;
  if(B[tmp].empty()) {
    depth[tmp] = max(depth[tmp], 1);
  } else {
    for(auto ne: B[tmp]) {
      if(vis[ne]) {
        if(vis2[ne]) flag = true;
        depth[tmp] = max(depth[tmp], depth[ne]+1);
      } else {
        vis[ne] = true;
        vis2[ne] = true;
        dfs(B, ne, len+1, vis, vis2, flag, depth);
        depth[tmp] = max(depth[tmp], depth[ne]+1);
        vis2[ne] = false;
      }
    }
  }
}

int main() {
  int N;
  cin >> N;
  vector<vector<int> > mp(N, vector<int>(N));
  {
    int cnt = 0;
    rep(i, N) {
      REP(j, i+1, N) {
        mp[i][j] = cnt;
        mp[j][i] = cnt;
        cnt++;
      }
    }
  }
  vector<vector<int> > A(N, vector<int>(N-1));
  int M = N*(N-1)/2;
  vector<vector<int> > B(M), C(M);
  rep(i, N) {
    int prev;
    rep(j, N-1) {
      cin >> A[i][j];
      A[i][j]--;
      int tmp = mp[i][A[i][j]];
      if(j > 0) {
        B[prev].push_back(tmp);
        C[tmp].push_back(prev);
      }
      prev = tmp;
    }
  }
  bool flag = false;
  vector<bool> vis(M);
  vector<int> depth(M);
  rep(i, C.size()) {
    if(!vis[i]) {
      vis[i] = true;
      vector<bool> vis2(M);
      vis2[i] = true;
      dfs(B, i, 1, vis, vis2, flag, depth);
    }
  }
  int ans = -1;
  rep(i, M)
    ans = max(ans, depth[i]);
  if(flag)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}



Measured memory_bytes: 65152
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
using C = complex<double>;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int x, y; cin >> x >> y; C p1(x, y);
  cin >> x >> y; C p2(x, y);
  int q; cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> x >> y; C p(x, y);
    C x = p1 + real(conj(p2 - p1) * (p - p1)) / norm(p2 - p1) * (p2 - p1);
    cout << fixed << setprecision(10) << real(x) << ' ' << imag(x) << '\n';
  }
}


Measured memory_bytes: 3344
#!/usr/bin/env python3
import sys
import heapq

def solve(N: int, M: int, A: "List[int]"):
    A = [-a for a in A]
    heapq.heapify(A)
    for m in range(M):
        largest = -1 * heapq.heappop(A)
        largest = int(largest / 2)
        heapq.heappush(A, -1 * largest)

    print(-1 * sum(A))
    return

def solve_slow(N: int, M: int, A: "List[int]"):
    """
    遅い実行
    """
    A = sorted(A, reverse=True)
    m = 0
    while m < M:
        m += 1
        A[0] = A[0] // 2
        while m < M and len(A) > m and A[0] > A[M-m-1]:
            m += 1
            A[0] = A[0] // 2

        if (len(A) >= 2) and (A[0] < A[1]):
            tmp = A[0]
            A = A[1:]
            for i, a in enumerate(A):
                if a <= tmp:
                    A.insert(i, tmp)
                    break
                if i == len(A)-1:
                    A.insert(len(A)-1, tmp)
                    break
    print(sum(A))
    return




# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19452
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, k;
    cin >> n >> k;
    int per = 0;
    for(int i = k; i <= n; i += k)  ++per;
    ll ans = (ll)per * per * per;
    if(k % 2 == 0){
        per = 0;
        for(int i = k >> 1; i <= n; i += k) ++per;
        ans += (ll)per * per * per;
    }
    cout << ans << endl;
}

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

int main(){
    string a[150];
    int N,L;
    cin >> N >> L;
    for(int i = 0; i < N; i ++){
        cin >> a[i];
    }
    sort(a,a+N);
    for(int i = 0; i < N; i ++){
        cout << a[i];
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<int,int> P;

//long long gcd(long long a,long long b){
//	if(b==0) return a;
//	return gcd(b,a%b);
//}
//
//long long lcm(long long a,long long b){
//	
//	return a/gcd(a,b) * b;
//}

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

	int n;
	cin >> n;

	if(n < 1200) cout << "ABC\n";
	else if(n < 2800) cout << "ARC\n";
	else	cout << "AGC\n";
	
	return 0;
}

Measured memory_bytes: 256