akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long n;
  cin>>n;
  long long cnt[n]={};
  long long d[n];
  long long m;
  REP(i,n){
    cin>>d[i];
    m = max(m, d[i]);
    cnt[d[i]]++;
  }
  if(d[0] != 0){
    cout<<0<<endl;
    return 0;
  }
  if(cnt[0] > 1){
    cout<<0<<endl;
    return 0;
  }
  
  long long ans = 1;
  for(long long i = 1; i<=m; i++){
    ans *= po(cnt[i-1], cnt[i]);
    ans = mod(ans);
  }
  cout<<ans<<endl;
      
  return 0;
}

Measured memory_bytes: 1792
def myAnswer(N:int,D:int,X:int,A:list) -> int:
   total =  N
   for a in A:
      i = 1
      while i*a + 1 <= D:
         total += 1
         i  += 1
   return X + total

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   D,X = map(int,input().split())
   A = []
   for _ in range(N):
      A.append(int(input()))
   print(myAnswer(N,D,X,A[:]))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
ll n, freq[(int)2e5 + 5] = {}, mn = 1e9, mx = 0, arr[(int)2e5 + 5];
ll ans = 0;
int main()
{
    Hello
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        freq[arr[i]]++;
        mn = min(mn, arr[i]);
        mx = max(mx, arr[i]);
    }
    for(int i = mn; i <= mx; i++)
        ans += ((freq[i] * (freq[i] - 1)))/2;
    for(int i = 0; i < n; i++)
    {
        ll temp = ans;
        ans -= ((freq[arr[i]] * (freq[arr[i]] - 1)))/2;
        freq[arr[i]]--;
        ans += ((freq[arr[i]] * (freq[arr[i]] - 1)))/2;
        freq[arr[i]]++;
        cout << ans << endl;
        ans = temp;
    }
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cmath>

using namespace std;

#define MAX_N 1000001

bool p[MAX_N] = {false};
int like[MAX_N] = {0};
int acc[MAX_N + 1] = {0};

void sieve()
{
    int lim = sqrt(MAX_N);
    for (int i = 2; i <= MAX_N;i++)
    {
        p[i] = true;
    }
    
    for (int i = 2; i <= lim; i++)
    {
        if (p[i] == false)
        {
            continue;
        }
        int n = i * 2;
        for (int j = 2; n < MAX_N; j++)
        {
            n = i * j;
            p[n] = false;
        }
    }
}

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

    sieve();

    for (int i = 1; i <= MAX_N;i+=2)
    {
        if(p[i] && p[(i + 1)/2])
        {
            like[i] = 1;
        }
        acc[i] = acc[i - 1] + like[i];
        acc[i + 1] = acc[i];
    }

    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        if(l % 2 == 0)
        {
            cout << acc[r] - acc[l - 2] << endl;
        }
        else
        {
            cout << acc[r] - acc[l - 1] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 9976
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    List<String> list = new ArrayList<>();
    
    for(int i=0; i<s.length(); i++){
      if(list.size() == 0 && s.charAt(i) =='B'){
        continue;
      }
      
      if(s.charAt(i) == '0'){
        list.add("0");
      }
      if(s.charAt(i) == '1'){
        list.add("1");
      }
      if(s.charAt(i) == 'B'){
        list.remove(list.size()-1);
      }
    }
    for(int i=0; i<list.size(); i++){
      System.out.print(list.get(i));
    }
  }
}
    


Measured memory_bytes: 35480
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b)cout<<0<<endl;
	else cout<<max(0ll,(n-2)*(b-a)+1)<<endl;
}









Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;
    let text: String = read(s).unwrap();
    let text = check(text.as_str());
    println!("{}", text)
}

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn check(text: &str) -> &str {
    return if text == "ABC" { "ARC" } else { "ABC" }
}


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

int main() {
    int n; cin >> n;
    vector<tuple<string, int, int> > v;
    for (int i = 1; i <= n; i++) {
        string s; int p;
        cin >> s >> p;
        p = -p;
        v.emplace_back(tie(s, p, i));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        cout << get<2>(v[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char k[101][101];
int main(){
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>k[i][j];
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)
			cout<<k[i][j];
		cout<<endl;
		for(j=1;j<=m;j++)
			cout<<k[i][j];
		cout<<endl;
	}
}

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

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  ll ret =0;
  for (int i = 1; i < n - 1; ++i) {
    if(p[i-1] < p[i] && p[i] < p[i+1])
      ret++;
    if(p[i+1] < p[i] && p[i] < p[i-1])
      ret++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2") 
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define fast_az_fuk ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long 
#define int ll 
#define ull unsigned ll
#define ld long double 
#define pb push_back 
#define pf push_front
#define dll deque<ll> 
#define vll vector<ll> 
#define pll pair<ll,ll> 
#define mapll map<ll,ll>
#define endl "\n" 
#define all(v) v.begin(),v.end() 
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast_az_fuk
    ll a,b,c,d; cin>>a>>b>>c>>d;
    cout<<max({b*d,a*c,b*c,a*d});
    return 0;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int a, b;
    cin >> a >> b;
    if(a+b < 10)
        cout << a+b << endl;
    else
        cout << "error" << endl;
    return 0;
}

Measured memory_bytes: 3640
N=int(input())
B=list(map(int,input().split()))
A=[]

A.append(B[0])
for i in range(len(B)-1):
    A.append(min(B[i],B[i+1]))
A.append(B[len(B)-1])
max_sum=0
for i in A:
    max_sum+=i
print(max_sum)


Measured memory_bytes: 3060
#include <iostream>
#include <string>

int main()
{
	std::string str;

    std::cin >> str;

	if (str == "MON") {
		std::cout << 6;
	}
	else
	{
		if (str == "TUE") {
			std::cout << 5;
		}
		else
		{
			if (str == "WED") {
				std::cout << 4;
			}
			else
			{
				if (str == "THU") {
					std::cout << 3;
				}
				else
				{
					if (str == "FRI") {
						std::cout << 2;
					}
					else
					{
						if (str == "SAT") {
							std::cout << 1;
						}
						else
						{
							if (str == "SUN") {
								std::cout << 7;
							}
						}
					}
				}
			}
		}
	}
}

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

struct node{

  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left != NIL)
    x = x->left;

  return x;
}

Node treeMaximum(Node x){

  while(x->right != NIL)
    x = x->right;

  return x;
}

Node treeSearch(Node u, int k){

  if(u == NIL || k == u->key)
    return u;

  if(k < u->key)
    return treeSearch(u->left, k);

 else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){

  if(x->right != NIL)
    return treeMinimum(x->right);

  Node y = x->p;

  while(y != NIL && x == y->right){

    x = y;
    y = y->p;
  }

  return y;
}

void treeDelete(Node z){

  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;

  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;

  else
    x = y->right;

  if(x  != NIL)
    x->p = y->p;

  if(y->p == NIL)
    root = x;
    
    
  else if(y == y->p->left)
    y->p->left = x;

  else
    y->p->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k){

  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }

  z->p = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){

  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}

void preorder(Node u){

  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){

  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);

      Node t = treeSearch(root, x);

      if ( t != NIL )
        printf("yes\n");
      else
        printf("no\n");
    }
    else if ( com[0] == 'i' ){

    scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){

      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");

    } else if ( com[0] == 'd' ){

      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int x; cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 256
/* ************************************************************* */
/*     Author     : Mahabub.Tweety                               */
/*     Email      : mahabubrahman618@gmail.com                   */
/*     University : Comilla University, Bangladesh		         */
/*                  Department of Computer Science & Engineering */
/* ***************************************************************

/*
	Compiled : CNU c++ 14
	Copyright 2019 by Mahabub Rahman & Comilla University Sailor ; all rights reserved.
	Permission is granted for use in non-commercial applications provided this
	copyright notice remains intact   and unchanged.
*/


/*...................................Data_Types............................................*/

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<list>
#include<iterator>
#include<math.h>

using namespace std;

#define       ll                  long long int
#define       ull                  unsigned long long int
#define       veci                 vector<int>
#define       vecc                 vector<char>
#define       vecs                 vector<string>
#define       vecl                 vector<long long int>
#define       vecp                 vector<  pair<int,int> >
#define       mapstrint            map< string , int >
#define       mapstrstr            map< string , string >
#define       mapint               map< int, int >
#define       pb                   push_back
#define       pob                  pop_back
////============ CONSTANT ===============////
#define mx9   1000000009
#define mx7   10000007
#define mx6   1000006
#define mx5   100005
#define inf   1<<30                                           //infinity value
#define eps   1e-9
#define mx    (65540)
#define mod   1000000007
////=====================================////

long double PI = acosl(-1);
bool myfunc(int a, int b) //This function is use for descending order.
{
    return (a>b);
}
ll fact(ll n)
{
    if(n==0 || n==1) return 1;
    else return n*fact(n-1);
}

////======================================////

int main()
{
    ll n, i;
    cin >> n >> i;
    ll ans = n-(i-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> S(N);
  int p_i;
  int max = 0;
  for (int i = 0; i < N; ++i) {
    cin >> p_i;
    if (i > 0) {
      S[i] = S[i - 1] + p_i;
    } else {
      S[i] = p_i;
    }
    if (i >= K && max < S[i] - S[i - K]) {
      max = S[i] - S[i - K];
    } else if (i == K - 1) {
      max = S[i];
    }
  }
  cout << fixed << setprecision(10) << 0.5 * static_cast<double>(max + K)
       << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> 
void dbg_out(Head H, Tail... T) { 
    cerr << ' ' << H;
     dbg_out(T...); 
}
#define dbg(...) cerr << '(' << #__VA_ARGS__ << ')'<<':', dbg_out(__VA_ARGS__)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define on(val,pos) (val|(1<<pos))
#define off(val,pos) (val&(~(1<<pos)))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,k,q,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    cin>>n>>m>>q;
    vi row(n,0),col(m,0);
    vector<pii> arr(q);
    int maxa=0,maxb=0,cnta,cntb;
    for(i=0;i<q;i++){
        cin>>j>>k;
        j--;k--;
        row[j]++;
        col[k]++;
        if(row[j]==maxa)cnta++;
        else if(row[j]>maxa)maxa=row[j],cnta=1;
        
        if(col[k]==maxb)cntb++;
        else if(col[k]>maxb)maxb=col[k],cntb=1;

        arr[i]={j,k};
    }
    ll cnt=cnta*1ll*cntb;
    int ans=maxa+maxb;
    for(i=0;i<q;i++){
        int a=arr[i].x,b=arr[i].y;
        if(row[a]+col[b]==ans)cnt--;
    }

    if(cnt<=0)ans--;
    cout<<ans<<endl;
    //free();   //if pointer array
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, x, t;
  cin>>n>>x>>t;
  cout<<t*((n-1)/x+1)<<'\n';
  return 0;
}


Measured memory_bytes: 3636
#include <math.h>
#include <stdio.h>
#define rep(i, num) for ((i) = 0; (i) < (n); (i)++)

int main(void) {
    int i, n;
    double sum, m, v, sd;
    
    while (1) {
        scanf("%d", &n);
        
        if (n == 0) break;
        
        sum = 0;
        double s[n];

        rep(i, n) {
            scanf("%lf", &s[i]);
            sum += s[i];
        }
        m = sum / n;
        v = 0;
        rep(i, n) {
            v += (s[i]-m)*(s[i]-m);
        }
        sd = sqrt(v / n);
        printf("%lf\n", sd);
    }
    return 0;
}


Measured memory_bytes: 2040
class SegmentTree:
    """
    演算子は要素とセットでモノイドを形成するようなものでなければならない。
    すなわち、結合律が成り立ち単位元が存在する必要がある。(ただし単位元は添加可能)
    """
    @classmethod
    def all_identity(cls, operator, identity, size):
        return cls(operator, identity, [identity]*(2 << (size-1).bit_length()))

    @classmethod
    def from_initial_data(cls, operator, identity, data):
        size = 1 << (len(data)-1).bit_length()
        temp = [identity]*(2*size)
        temp[size:size+len(data)] = data
        data = temp

        for i in reversed(range(size)):
            data[i] = operator(data[2*i],data[2*i+1])
        return cls(operator, identity, data)

    # これ使わずファクトリーメソッド使いましょうね
    def __init__(self, operator, identity, data):
        self.op = operator
        self.id = identity
        self.data = data
        self.size = len(data)//2

    def _interval(self, a, b):
        a += self.size
        b += self.size
        ra = self.id
        rb = self.id

        data = self.data
        op = self.op
        while a < b:
            if a & 1:
                ra = op(ra,data[a])
                a += 1
            if b & 1:
                b -= 1
                rb = op(data[b],rb)
            a >>= 1
            b >>= 1
        return op(ra,rb)

    def __getitem__(self, i):
        if isinstance(i, slice):
            return self._interval(
                                    0 if i.start is None else i.start,
                                    self.size if i.stop is None else i.stop)
        elif isinstance(i, int):
            return self.data[i+self.size]

    def __setitem__(self, i, v):
        i += self.size
        data = self.data
        op = self.op
        while i:
            data[i] = v
            v = op(data[i^1],v) if i & 1 else op(v,data[i^1])
            i >>= 1

    def __iter__(self):
        return iter(self.data[self.size:])

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

L = 300000
N,K = map(int,readline().split())
seg = SegmentTree.all_identity(max2, 0, L+1)

for a in map(int,read().split()):
    seg[a] = seg[max2(0,a-K):min2(L,a+K)+1]+1

print(seg[:])

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

int main () {
  int n, count; cin >> n;
  for (int i=1;i<=n;i++) {
    if (i<10 || (100<=i && i<1000) || (10000<=i && i<100000)) {
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
extern crate core;

use std::collections::HashMap;
use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

/*
LがNとMの公倍数
L/N*i

L=i*N*M/gcd(N,M)

L=i*lcm(N,M)

L/N*j
L/M*j


i*M/gcd(N,M)*j
i*N/gcd(N,M)*j

N=2
M=3
L=6
0,3,6,9,12...
0,2,4,6,8,10,12
一致
0,6,12
 */

fn solve(input: String) -> String {
    input!(input=>(n:usize m:usize)(s:#)(t:#));
    let s = s.chars().collect::<Vec<_>>();
    let t = t.chars().collect::<Vec<_>>();
    let nm_lcm = lcm(m, n);
    let mut s_map = HashMap::new();
    let mut t_map = HashMap::new();

    for i in 0..n {
        let a = i * nm_lcm / n;
        s_map.insert(a, s[i]);
    }

    for i in 0..m {
        let a = i * nm_lcm / m;
        t_map.insert(a, t[i]);
        if let Some(x) = s_map.get(&a) {
            if t[i] != *x {
                return "-1".to_string();
            }
        }
    }

    nm_lcm.to_string()
}

pub fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

//最小公倍数
pub fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 2\nacp\nae\n" => "6\n",
    test2: "6 3\nabcdef\nabc\n" => "-1\n",
    test3: "15 9\ndnsusrayukuaiia\ndujrunuma\n" => "45\n",
}


Measured memory_bytes: 16536
n, m = map(int, raw_input().split())
balls = [1] * n
reds = [False] * n
reds[0] = True

for _ in range(m):
    a, b = map(int, raw_input().split())
    a -= 1
    b -= 1
    balls[a] -= 1
    balls[b] += 1

    if reds[a]:
        reds[b] = True

    if balls[a] == 0:
        reds[a] = False

print(reds.count(True))

Measured memory_bytes: 7300
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    ll ans;
    for(ll i = 0; i < n-1; i++){
        if(a[i]<=a[n-1]/2 && a[i+1]>=a[n-1]/2){
            if(a[i]>=a[n-1]-a[i+1]) ans = a[i];
            else ans = a[i+1];
        }
    }
    cout << a[n-1] << " " << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import math

def main():
    na = list(map(int, input().split()))
    N = na[0]
    H = na[1]
    a = []
    b = []
    for i in range(N):
        na = list(map(int, input().split()))
        a.append(na[0])
        b.append(na[1])

    a_max = max(a)
    b.sort()

    h = 0
    i = 0
    while h < H:
        if N <= i:
            i += math.ceil((H - h) / a_max)
            break
        if b[N - 1 - i] <= a_max:
            h += a_max
        else:
            h += b[N - 1 - i]
        i += 1

    print(i)


if __name__ == '__main__':
    main()



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


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(ALL(h));
    if(k > n) k = n;
    rep(i,k) h.pop_back();
    ll ans = 0;
    if (h.size() > 0) {
        rep(i, n-k) ans += h[i];
    }
    
    cout << ans << "\n";
}


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

struct Card {
	char suit[2];
	int num;
};

void printList(Card num[], int n){
	for (int i = 0; i < n; i++){
		cout << num[i].suit;
		if (i != n-1) cout << ' ';
	}
	cout << endl;
}

void swap(int *x, int *y){
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

void swapCard(Card *x, Card *y){
	Card tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

int bubbleSort(Card num[], int n){
	int count = 0;
	for (int i = 0; i < n; i++){
		for (int j = n-1; j > i; j--){
			if (num[j].num < num[j-1].num){
				swapCard(&num[j], &num[j-1]);
				count++;
			}
		}
	}
	return count;
}

int selectionSort(Card num[], int n){
	int min, j, count = 0;
	for (int i = 0; i < n; i++){
		min = i;
		for (j = i; j < n; j++){
			if (num[min].num > num[j].num)
				min = j;
		}
		if (min != i){
			swapCard (&num[min], &num[i]);
			count++;
		}
	}
	return count;
}

void copy(Card target[], Card source[], int n){
	for (int i = 0; i < n; i++)
		target[i] = source[i];
}

bool isStable(Card in[], Card out[], int n){
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){//前两层循环遍历所有两个数的情况
			for (int a = 0; a < n; a++){//i与j分别代表两个数
				for (int b = a+1; b < n; b++){//
					if (in[i].num == in[j].num && 
					strcmp(in[i].suit, out[b].suit) == 0 &&
					strcmp(in[j].suit, out[a].suit) == 0)
						return false;
				}
			}
		}
	}
	return true;
}

int main(){
	Card n[36], tmp[36];
	int limit;
	cin >> limit;
	for (int i = 0; i < limit; i++){
		cin >> n[i].suit;
		n[i].num = (int)(n[i].suit[1] - '0');
	}
	copy(tmp, n, 36);
	bubbleSort(n, limit);
	printList(n, limit);
	if (isStable(tmp, n, limit))
		cout << "Stable" << endl;
	else
		cout << "Not Stable" << endl;
	copy(n, tmp, 36);
	selectionSort(n, limit);
	printList(n, limit);
	if (isStable(tmp, n, limit))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
//	cout << count << endl;
	return 0;
}


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

using namespace std;

int main(void) {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N), grid(H*W);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    int s = 0;
    for(int i=0; i<N; i++) {
        for(int j=s; j<s+a[i]; j++) {
            grid[j] = i+1;
        }
        s += a[i];
    }

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(i%2) {
                cout << grid[i*W + W-1-j] << " ";
            } else {
                cout << grid[i*W + j] << " ";
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    s=str(input())
    cnt=0
    for i in range(N):
        if s[i]=='R':
            cnt+=1
    print('Yes' if cnt>N-cnt else 'No')
    
resolve()

Measured memory_bytes: 38384
$n=<>;
$i++,$x|=$_>0,$w|=$_<0,$M=$M<$_?($d=$i,$_):$M,$m=$m>$_?($e=$i,$_):$m for@a=glob<>;
print$n*($w&$x?2:1)-1,$/;
if($w&$x){
	print"${$M>-$m?d:e} $_\n
	"for($w=1)..$n;
	${$M>-$m?w:x}=0
}
if($x){
	print$_,$",$_+1,$/for 1..$n-1
}
else{
	print$n-$_+1,$",$n-$_,$/for 1..$n-1
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int n, m;
ll ans;
int a[100005];
ll dp[100005];

int main() {

	a[0] = 1;

	cin >> n >> m;
	rep(i, m) {
		int tmp;
		cin >> tmp;
		a[tmp] = 1;
	}

	dp[0] = 1;
	if (a[1])dp[1] = 0;
	else dp[1] = 1;

	REP(i, 2, n + 1) {
		if (a[i]) {
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 1408
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    n = getN()
    li = [0 for i in range(n)]
    for nn in getList():
        # nn = getN()
        li[nn-1] += 1

    for nn in li:
        print(nn)

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long[] a = new long[n + 1];
			for (int i = 0; i < n + 1; i++) {
				a[i] = cin.Long();
			}

			long[] b = new long[n];
			for (int i = 0; i < n; i++) {
				b[i] = cin.Long();
			}

			long count = 0;
			for (int i = 0; i < n; i++) {
				long temp = Math.Min(a[i], b[i]);
				count += temp;
				b[i] -= temp;
				if (b[i] != 0) {
					long temp2 = Math.Min(a[i + 1], b[i]);
					count += temp2;
					a[i + 1] -= temp2;
				}
			}

			Console.WriteLine(count);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 31848
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;

int main()
{
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) puts("Bad");
	else puts("Good");
	rt0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])

A=sorted(A,key=lambda x:x[0])
ko=0
pri=0
i=0
while ko<=m:
  pri+=A[i][0]*A[i][1]
  ko+=A[i][1]
  i+=1
  if ko==m:
    print(pri)
    exit()
print(pri-(ko-m)*A[i-1][0])

Measured memory_bytes: 21972
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x,k,d = mi()
x = abs(x)

count = min(k,x//d)
k -= count
x -= d*count

if k % 2 == 0:
    print(x)
else:
    print(d-x)

Measured memory_bytes: 9396
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int i,n,m,x,ans,sum;

	while(1){
		scanf("%d",&n);
		if(n==0)break;
		
		ans=-100000;sum=0;i=0;
		int* a = (int*)malloc(sizeof(int)*(n+1));
		a[0]=0;

		for(1;n>0;n--){
			scanf("%d",&x);
			if(ans<=0 && x<=0){if(ans<x)ans=x;}
			else{
				ans=1;
				if(sum*x>=0)sum+=x;
				else{
					a[++i]=a[i-1]+sum;
					sum=x;
				}
			}
		}
		if(sum>0)a[++i]=a[i-1]+sum;

		if(ans>0){
			for(n=0;n<=i;n+=2){
				for(m=n+1;m<=i;m++){
					if(a[m]-a[n]>ans)ans=a[m]-a[n];
				}
			}
		}

		free(a);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <string.h>

int main(void){
	int field[100][100], x, y, w, h, i, j, k, l, n, s, t, max, count;
	while(1){
		scanf("%d",&n);
		if(n == 0)
			break;
		scanf("%d%d",&w,&h);
		memset(field,0,sizeof(field));
		for(i = 0;i < n;i++){
			scanf("%d%d",&x,&y);
			field[y - 1][x - 1] = 1;
		}
		max = -1;
		scanf("%d%d",&s,&t);
		for(i = 0;i < h - t + 1;i++){
			for(j = 0;j < w - s + 1;j++){
				count = 0;
				for(k = 0;k < t;k++){
					for(l = 0;l < s;l++)
						if(field[i + k][j + l])
							count++;
				}
				if(max < count)
					max = count;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

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

typedef long long ll;

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

    ll w[N], v[N];
    for(int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    ll INF = 1e9+1;
    ll max_v = 1000 * 100;
    ll dp[max_v + 1];

    // dp[i]: 価値iを作れる時の重さの最小値
    // 最小値を得たいので、INFをあらかじめ代入
    for(int i = 0; i < max_v + 1; i++){
        dp[i] = INF;
    }
    
    // dpの要素番号 = 価値
    dp[0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = max_v; j >= 0; j--){
            if(j - v[i-1] >= 0){
                dp[j] = min(dp[j], dp[j-v[i-1]] + w[i-1]);
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i <= max_v; i++){
        if(dp[i] <= W){
            // dpに格納したウェイトがW以下の場合、その要素番号と
            // ansのくらいを比較する
            ans = max(ans, (ll)i);
        }
    }

    cout << ans << endl;
}


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

int main(int argc, char const *argv[])
{
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main(){
   ll n;cin >>n;
   vector<ll>a(n+1,0);
   ll ans=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        ans=__gcd(ans,a[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int i,k,n,num;
  int card[4][13];
  char kind;

  scanf("%d", &n);
  
  for(i=0; i<4; ++i){
    for(k=0; k<13; ++k){
      card[i][k] = 0;
    }
  }


  char work;
  for(i=0; i<n; ++i){
    scanf("%c",&work);
    if(work == '\n'){
      scanf("%c",&kind);
    }else{
      kind = work;
    }
    scanf("%d",&num);
    if(kind == 'S')      card[0][num - 1] = 1;
    else if(kind == 'H') card[1][num - 1] = 1;
    else if(kind == 'C') card[2][num - 1] = 1;
    else                 card[3][num - 1] = 1;  
   }


  
  for(i=0; i<4; ++i){
    for(k=0; k<13; ++k){
      if(card[i][k] == 0){
	if(i == 0)     printf("S %d\n",k+1);
	else if(i == 1)printf("H %d\n",k+1);
	else if(i == 2)printf("C %d\n",k+1);
	else if(i == 3)printf("D %d\n",k+1);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int gcd(int a, int b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

int extend_gcd(int a[], int n) {
  if(n < 2) return -1;
  int rsl = gcd(a[0], a[1]);
  rep(i, 2, n) {
    rsl = gcd(a[i], rsl);
  }
  return rsl;
}

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

  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];
  vector<int> tmp = divisor(extend_gcd(a, n));
  vsort(tmp);
  for(auto it = tmp.begin(); it != tmp.end(); ++it) {
    cout << *it << endl;
  }
}




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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n,k; cin>>n>>k;
	int64_t ans=0;
	for(int64_t i=k+1;i<=n;++i){
		ans+=n/i*(i-k)+max(0l,n%i-k+1);
	}
	if(!k)ans-=n-k;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9+7

def factorial_mod(x, y, mod):
    factorial = 1
    for i in range(x,y+1):
        factorial *= i
        factorial %= mod
    return factorial


#conbinationを何回も求める場合はfactorial_k,nkをあらかじめ計算し, リストに入れておけば良い
def n_C_k(n,k,mod):
    factorial_nk = factorial_mod(n-k+1, n, mod)
    factorial_k = factorial_mod(1,k,mod)
    conbi=factorial_nk*pow(factorial_k, mod-2, mod)
    return conbi%mod

ans = (pow(2, n, mod)-1-n_C_k(n, a, mod)-n_C_k(n, b, mod))%mod
print(ans)


Measured memory_bytes: 39152
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());

		if (n == 1) {
			Console.WriteLine(1);
		} else {
			long n1 = 2;
			long n2 = 1;
			for (var i = 1; i < n; ++i) {
				long temp = n2;
				n2 = n1 + n2;
				n1 = temp;
			}

			Console.WriteLine(n2);
		}

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 13140
#include <stdio.h>

int fib(int n){
  int i;
  int F[44];
  F[0]=1;
  F[1]=1;
  for(i=2;i<=44;i++)F[i]=F[i-2]+F[i-1];
  return F[n];
}



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

}



Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel kai(4001, 1);
vel ink(4001, 1);
int le = (1 << 20) + 1;
vel BIT(le, 0);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	list = ql;
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 4000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 4001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
signed main() {
	int n, m; cin >> n >> m;
	vel a(n);
	rep(i, n) { cin >> a[i]; }
	sor(a);
	V<pin> bc(m);
	rep(i, m) { int b, c; cin >> b >> c; bc[i] = mkp(c, b); }
	sor(bc); reverse(bc.begin(), bc.end());
	int itr = 0;
	rep(i, m) {
		int qitr = itr;
		for(;itr<min(qitr+bc[i].second,n);itr++) {
			mmax(a[itr], bc[i].first);
		}
	}
	int sum = 0;
	rep(i, n) { sum += a[i]; }
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	int n = s.size();
	ll res = 0;
	rep(i,n){
		res += s[i] - '0';
	}
	if(res % 9 == 0) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3724
import java.util.Scanner;
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();

        boolean is1 = A == B;
        boolean is2 = B == C;
        boolean is3 = C == A;

        if (is1 && !is2 && !is3) {
            System.out.println("Yes");
        } else if (!is1 && !is2 && is3) {
            System.out.println("Yes");
        } else if (!is1 && is2 && !is3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <numeric>
#include <utility>
#include <algorithm>
using namespace std;
using Int = int64_t;
Int solve() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (auto& i : A) cin >> i;
    for (auto& i : B) cin >> i;
    if (accumulate(A.begin(), A.end(), (Int)0) < accumulate(B.begin(), B.end(), (Int)0)) return -1;
    vector<int> g, l;
    for (int i = 0; i < N; i++) {
        auto t = A[i] - B[i];
        if (t > 0) g.push_back(t);
        else if (t < 0) l.push_back(-t);
    }
    if (l.size() == 0) return 0;
    sort(g.begin(), g.end(), greater<int>());
    auto t = accumulate(l.begin(), l.end(), (Int)0);
    for (size_t i = 0; i < g.size(); i++) {
        t -= g[i];
        if (t <= 0) return l.size() + i + 1;
    }
    return -1;
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 1660
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;

const int MAX_N = 16;

int N, T;

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

    cin >> N >> T;

    int ans = 0;
    int prevt = 0;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        ans += prevt + T <= t ? T : t - prevt;
        prevt = t;
    }
    ans += T;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3592