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

int repl(string str){
  int N=str.size();
  if(N==0) return 0;
  int cnt=1;
  int result=0;
  for(int i=1; i<N; i++){
    if(str[i-1]==str[i]){
      cnt++;
    }else{
      result+=cnt/2;
      cnt=1;
    }
  }
  return result+cnt/2;
}

int main(){
  string S; long long K; cin >> S >> K;
  int N=S.size();
  if(S.front()==S.back()){
    string R=S;
    sort(R.begin(),R.end());
    if(R.front()==R.back()){
      cout << N*K/2 << endl;
    }else{
      int a=0,b=0;
      for(int i=0; i<N; i++){
        if(S[i]==S[0]) a++;
        else break;
      }
      for(int i=0; i<N; i++){
        if(S[N-1-i]==S[N-1]) b++;
        else break;
      }
      cout << a/2+b/2+((a+b)/2)*(K-1)+repl(S.substr(a,N-a-b))*K << endl;
    }
  }else{
    cout << repl(S)*K << endl;
  }
}

Measured memory_bytes: 256
M = int(input())
D = []
C = []
for i in range(M):
    d,c = map(int,input().split())
    D.append(d)
    C.append(c)

ans = 0
n = D[0]
C[0] -= 1
for i in range(M):
    c = C[i]
    d = D[i]
    while c != 0:
        if c%2==0:
            ans += c//2*((2*d)//10+1)
            d = (2*d)//10+(2*d)%10
            c //= 2
        else:
            ans += c//2*((2*d)//10+1)
            ans += (n+d)//10+1
            n = (n+d)//10+(n+d)%10
            d = (2*d)//10+(2*d)%10
            c //= 2
print(ans)

Measured memory_bytes: 72724
n = int(input())
s = input()

ans = 0
for i in range(1,n-1):
    mae = s[:i]
    ato = s[i:]
    temp = []
    for j in mae:
        if j in ato:
            temp.append(j)
    temp = set(temp)
    ans = max(ans,len(temp))

print(ans)

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

int N;

int main(){
    while(cin >> N && N){
        int ans = 0;
        for(int i=N+1;i<=2*N;i++){
            int ok = 1;
            for(int j=2;j*j<=i;j++){
                if(i!=j && i%j==0) ok = 0;
            }
            ans += ok;
        }
        cout << ans << endl;
    }
}


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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i = 0;i < n;i++) cin>>a[i];
    for(int j = 0;j < n;j++) cin>>b[j];
    for(int j = 0;j < n-1;j++) cin>>c[j];
    int ans = b[a[0]-1];
    for(int i = 1;i < n;i++) {
        ans += b[a[i]-1];
        if(a[i] - a[i-1] == 1) {
            ans += c[a[i-1]-1];
        }
    }    
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  vector<int> vecnew(n);
  for(int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  //アルゴリズムはO(logn)なので
  k = min(k, 41);
  for(int i = 0; i < k; i++) {
    vecnew.assign(n, 0);
    //累積和のテクニック
    for(int j = 0; j < n; j++) {
      int s = max(0, j - vec[j]);
      int l = min(n - 1, j + vec[j]);
      vecnew[s]++;
      if(l + 1 < n) {
        vecnew[l + 1]--;
      }
    }
    for(int j = 1; j < n; j++) {
      vecnew[j] += vecnew[j - 1];
    }
    for(int j = 0; j < n; j++) {
      vec[j] = vecnew[j];
    }
  }
  for(int i = 0; i < n - 1; i++) {
    cout << vec[i] << " ";
  }
  cout << vec[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 4804
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int M;
	cin >> M;
	cout << 48 - M << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <queue>
#include <cstring>

using namespace std;

typedef long long ll;

const int N=500010;
char c[N];
int ru[N],ans[N],hed[N],ver[N],nex[N],tot;
ll sum;
queue<int> q;

void add(int x,int y)
{
	tot++;
	ver[tot]=y;
	nex[tot]=hed[x];
	hed[x]=tot;
}

int main()
{
    int i,x,y;
	cin>>c;
	int n=strlen(c);
	for(i=0;i<n;i++)
    {
		if(c[i]=='<')
        {
			add(i,i+1);
			ru[i+1]++;
		}
		else
        {
			add(i+1,i);
			ru[i]++;
		}
	}
	for(i=0;i<=n;i++)
    {
		if(ru[i]==0)
        {
			ans[i]=0;
			q.push(i);
		}
	}
	while(!q.empty())
    {
		x=q.front();
		q.pop();
		for(i=hed[x];i;i=nex[i])
        {
			y=ver[i];
			ru[y]--;
            ans[y]=max(ans[y],ans[x]+1);
			if(ru[y]==0) q.push(y);
		}
	}
    for(i=0;i<=n;i++) sum+=ans[i];
	cout<<sum;
//    system("pause");
	return 0;
}


Measured memory_bytes: 14320
# -*- coding: utf-8 -*-

#k回対戦済

S = input()

#リストに変換
S_list = []
for i in range(0,len(S)):
    S_list.append(S[i])
#print(S_list)

#勝ち数
Nvic = S_list.count("o")

if Nvic + 15 - len(S) < 8:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[ohara][13];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    if(Size(s)==1){
        Cout(1);
        return 0;
    }
    rep(i,Size(s)+1)rep(j,3)dp[i][j]=-LINF;
    dp[0][0]=1;
    if(s[0]!=s[1])dp[1][0]=2;
    dp[1][1]=1;
    rrep(i,2,Size(s)){
        //0の更新
        if(s[i]==s[i-1])dp[i][0]=dp[i-1][1]+1;
        else dp[i][0]=max(dp[i-1][0],dp[i-1][1])+1;
        //1の更新
        dp[i][1]=max(dp[i-2][0],dp[i-2][1])+1;
    }
    ans=max(dp[Size(s)-1][0],dp[Size(s)-1][1]);
    Cout(ans);
    return 0;
}

Measured memory_bytes: 21012
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int dp[11][2020];
int main(){
	int n,k,c,g;
	vector<int>G[11];
	cin>>n>>k;
	REP(i,n){
		cin>>c>>g;
		G[--g].PB(c);
	}
	REP(i,10){
		sort(ALL(G[i]));
		G[i].PB(0);
		reverse(ALL(G[i]));
		for(int j=1;j<G[i].size()-1;j++)G[i][j+1]+=G[i][j];
		for(int j=1;j<G[i].size();j++)G[i][j]+=j*(j-1);
	}
	REP(i,10){
		if(i==0){
			REP(j,G[0].size())dp[i][j]=G[i][j];
		}else{
			REP(j,n){
				for(int l=0;l<G[i].size()&&l+j<=n;l++){
					dp[i][l+j]=max(dp[i][l+j],dp[i-1][j]+G[i][l]);
				}
			}
		}
	}
	cout<<dp[9][k]<<endl;
}

Measured memory_bytes: 1312
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

s = 0
for i in range(N):
    s += B[A[i]-1]
    try:
        if A[i]+1 == A[i+1]:
            s += C[A[i]-1]
    except:
        pass

print(s)


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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


using namespace std;


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int a, b, c;
	cin >> a >> b >> c;
	long long int k;
	cin >> k;
	long long int countt = 0;
	while (a >= b)
	{
		b = b * 2;
		countt++;
	}
	while (b >= c)
	{
		c = c * 2;
		countt++;
	}
	if (countt <= k)
		cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	return 0;


}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

ll dp[200100][3];

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

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

  rep(i, n+1){
    rep(j, 3){
      dp[i][j] = -INF;
    }
  }

  dp[0][0] = 0;

  rep(i, n){
    
    // そのまま
    if(i%2==0){
      chmax(dp[i+1][0], dp[i][0] + a[i]);
      chmax(dp[i+1][1], dp[i][1]);
      chmax(dp[i+1][2], dp[i][2] + a[i]);
    }else{
      chmax(dp[i+1][0], dp[i][0]);
      chmax(dp[i+1][1], dp[i][1] + a[i]);
      chmax(dp[i+1][2], dp[i][2]);
    }

    // 1個増やす
    chmax(dp[i+1][1], dp[i][0]);
    chmax(dp[i+1][2], dp[i][1]);

  }

  if(n%2==0){
    cout << dp[n][1] << endl;
  }else{
    cout << dp[n][2] << endl;
  }

  return 0;
}


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

int main(){
  long x,x2,i,j;
  bool* p;
  cin >> x;
  x2 = x*2;
  p = new bool[x2];
  for(i=0;i<x2;i++)
    p[i] = true;
  for(i=2;i<x2;i++){
    if (p[i]){
      if (i >= x){
        cout << i << endl;
        break;
      }
      for(j=i*2;j<x2;j+=i)
        p[j] = false;
    }
  }
  return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h> 
using namespace std;
typedef long long LL;
LL a[255],ans;
char s[205050];
int main(){
	scanf("%s",s);
	ans = 0;
	for (LL i=0;s[i];i++) {
		ans+=i-a[s[i]];
		a[s[i]]++;
	}
	printf("%lld\n",ans+1);
}


Measured memory_bytes: 384
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {x: i128, k: i128, d: i128};

    let d1: i128 = x.abs() % d;
    let r = x.abs() / d;

    if r < k {
        if (r - k) % 2 == 0 {
            println!("{}", d1.abs())
        } else {
            println!("{}", (d.abs() - d1.abs()).abs())
        }
    } else {
        if x < 0 {
            println!("{}", (x + k * d).abs())
        } else {
            println!("{}", (x - k * d).abs())
        }
    }
}


Measured memory_bytes: 2200
a,b,m = map(int, input().split(' '))
a_ = list(map(int, input().split(' ')))
b_ = list(map(int, input().split(' ')))
res = min(a_) + min(b_)
for i in range(m):
    x,y,c = map(int, input().split(' '))
    z = a_[x-1] + b_[y-1] - c
    if res > z:
        res = z
print(res)

Measured memory_bytes: 18648
import sys
def 解():
    input = sys.stdin.readline
    N = int(input())
    dp = [int(_) for  _ in input().split()]
    for _ in range(N-1):
        a,b,c = [int(_) for  _ in input().split()]
        dp = [max(dp[1]+a,dp[2]+a),max(dp[0]+b,dp[2]+b),max(dp[0]+c,dp[1]+c)]
    print(max(dp))
解()

Measured memory_bytes: 3316
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val a = sc.nextInt
  val b = sc.nextInt

  val res = if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) "Possible" else "Impossible"

  println(res)
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll A, B, V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if( (V-W) * T >= abs(B-A) ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

//#define DEBUG


int main(void)
{
  int a,b;
  cin >> a >> b;
  // 同じ場合は？
  string A,B;
  //A代入
  for(int i=0;i<b;i++) A += to_string(a);
  for(int i=0;i<a;i++) B += to_string(b);
  if(a<b)
  {
    cout << A;
  }
  else
  {
    cout << B;
  }

  return 0;
} 

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

using namespace std;

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

Measured memory_bytes: 256
sss = input().split()
while sss:
    a,b = int(sss[0]), int(sss[1])
    ab = a + b
    c = 1
    while ab // 10 > 0:
        c += 1
        ab //= 10
    print(c)
    try: sss = input().split()
    except EOFError: break


Measured memory_bytes: 7520
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

ll L[1000001];

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void Lin(ll x){
    ll y=x;
    for(ll i=2;i*i<=x;i++){
        ll a=0;
        while(y%i==0){
            y/=i;
            a++;
        }
        if(L[i]<a) L[i]=a;
    }
  if(y>1 && L[y]<1) L[y]=1;
}

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,1000001) L[i]=0;
    rep(i,n) cin >> a[i];
    rep(i,n) Lin(a[i]);
    
    //LCMの代わり
    ll c=1;
    for(ll i=1;i<1000001;i++){
        rep(j,L[i]) c=(c*i)%inf;
    }
    
    ll ans=0;
    
    rep(i,n){
        ans = ( (c * modinv(a[i], inf) ) % inf + ans ) % inf; 
    }
    kaku(ans);
}




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

int main(){
 int A;
 int B;
 int C;
 long long int a;
 bool ans=false;
 int amari;
 int i=0;
 cin>>A>>B>>C;
 
 a=A;
 amari=A%B;
 if(amari==C) ans=true;
 a=a+A;
 
 while(i<10){
  if(a%B==C){
  	ans=true;
	break;
  }
  if(a%B==amari) break;
  a=a+A;
 }
 
 if(ans==0) cout<<"NO"<<endl;
 if(ans==1) cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, x;
    scanf("%d%d", &n, &x);
    int m[100];
    for (int i = 0; i < n; i++) {
        scanf("%d", &m[i]);
        x -= m[i];
    }
    sort(m, m+n);
    printf("%d\n", n+x/m[0]);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;


struct SegT {
private:
	int n; vector<ll> node,lazy;
	const ll init_c = -INF;
public:
	SegT(int sz) {
		n = 1;
		while (n < sz)n <<= 1;
		node.resize(2 * n - 1, init_c);
		lazy.resize(2 * n - 1, 0);
	}
	ll f(ll a, ll b) {
		return max(a, b);
	}
	void eval(int k, int l, int r) {
		node[k] += lazy[k];
		if (r - l > 1) {
			lazy[2 * k + 1] += lazy[k];
			lazy[2 * k + 2] += lazy[k];
		}
		lazy[k] = 0;
	}
	void add(ll x, int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x; eval(k, l, r);
		}
		else {
			add(x, a, b, k * 2 + 1, l, (l + r) / 2);
			add(x, a, b, k * 2 + 2, (l + r) / 2, r);
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	ll query(int a, int b, int k = 0, int l = 0, int r =-1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return init_c;
		if (a <= l && r <= b)return node[k];
		else {
			ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
	void update(int k, ll x) {
		ll z = query(k, k + 1);
		add(x - z, k, k + 1);
	}
};
vector<LP> v[1 << 18];
int n, m;
int main() {
	cin >> n >> m;
	SegT st(n + 2);
	rep(i, m) {
		int l, r; ll a; cin >> l >> r >> a;
		v[l].push_back({ l,a });
		v[r + 1].push_back({ l,-a });
	}
	ll ans = 0;
	st.update(0, 0);
	rep1(i, n + 1) {
		rep(j, v[i].size()) {
			st.add(v[i][j].second, 0, v[i][j].first);
		}
		ll memo = st.query(0, i);
		ans = max(ans, memo);
		st.update(i,memo);
		//cout << memo << endl;
	}
	cout << ans << endl;
	//stop
	return 0;
}

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

using ll = long long;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    set<int> s{1, 2,3};
    s.erase(a);
    s.erase(b);
    cout << *s.begin() << '\n';
    return 0;
}

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

int main()
{
	int n; cin >> n;
	
	deque<int> dq;
	for (int i = 0; i < n; i++) {
		int tmp_a;
		cin >> tmp_a;
	
		if (i % 2 == 0) {
			dq.emplace_front(tmp_a);
		}
		else {
			dq.emplace_back(tmp_a);
		}
	}

	if (n % 2 == 0) reverse(dq.begin(), dq.end());

	for (auto itr = dq.begin(); itr != dq.end(); ++itr) {
		cout << *itr << " ";
	}

	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ld sum = 0;
    int N;
    cin >> N;
    ld x[N], y[N];
    for (size_t i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    vector<int> v(N);
    for (size_t i = 0; i < N; i++) {
        v[i] = i;
    }
    do {
        for (size_t i = 0; i < N - 1; i++) {
            sum += sqrtl(powl(x[v[i]] - x[v[i + 1]], 2) + powl(y[v[i]] - y[v[i + 1]], 2));
        }
    } while (next_permutation(v.begin(), v.end()));
    for (size_t i = 1; i <= N; i++) {
        sum /= (ld)i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N;
	cin >> N;

	vector<ll> A;
	for (int i = 0; i < N; i++) {
		ll temp;
		cin >> temp;
		A.emplace_back(temp);
	}

	ll minus = 0;
	bool zero = false;
	for (int i = 0; i < N; i++) {
		if (A[i] < 0) {
			minus++;
		}
		if (A[i] == 0) {
			zero = true;
		}
	}



	ll ans = 0;
	if (minus % 2 == 0 || zero) {
		for (int i = 0; i < N; i++) {
			ans += abs(A[i]);
		}
		cout << ans;
		return 0;
	}
	else {
		ll minA = LLINF;
		for (int i = 0; i < N; i++) {
			minA = min(minA, abs(A[i]));
		}
		for (int i = 0; i < N; i++) {
			ans += abs(A[i]);
		}
		cout << ans - 2 * minA;

	}




}





Measured memory_bytes: 1400
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [a, b] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)
const s = stdin.split('\n')[1]

const ans = () => {
  const reg = new RegExp(`^\\d{${a}}-\\d{${b}}$`, 'g')

  const isOk = reg.test(s)

  console.log(isOk ? 'Yes' : 'No')
}

ans()


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

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}
ll modComb(ll n,ll a){
  ll x=1,y=1;
  rep(i,a){
    x*=n-i;
    x%=MOD;
    y*=i+1;
    y%=MOD;
  }
  y=modPow(y,MOD-2);
  return (x*y)%MOD;
}

int main(){
  ll A,P;
  cin >> A >> P;
  cout << (A*3+P)/2 << endl;
}

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

def find_the_same(itter, number, answer_list):
    if itter == 1:
        answer_list.append(number)
    if number%2 == 0:
        answer = number // 2
    else:
        answer = (number * 3) + 1
    if answer in answer_list:
        itter += 1
        return itter
    else:
        itter += 1
        answer_list.append(answer)
        return find_the_same(itter, answer, answer_list)
answer_list = []
print(find_the_same(1, s, answer_list))


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    map<int,int> cnt;
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;
    for(auto itr=cnt.begin(); itr!=cnt.end(); itr++) {
        int key = itr->first;
        int val = itr->second;
        if(key < val) {
            ans += val - key;
        } else if(key > val) {
            ans += val;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
  
inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
  
inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
  
  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;
  
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
  
  std::cout << (gap_num+1) << '\n';
  
  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';
  
  std::cout << count << '\n';
}
  
int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
ll a[510];
ll k;
ll sum=0;
vector<ll> pr_fa;
/*vector<ll> prime;
ll is_prime[100100]={};
void make_primelist(){
	prime.push_back(2);
	is_prime[2]=1;
	for(ll i=3;i<30100;i++){
		ll flag=1;
		for(ll j=0;prime[j]*prime[j]<=i;j++){
			if(i%prime[j]==0){
				flag=0;
				break;
			}
		}
		if(flag){
			is_prime[i]=1;
			prime.push_back(i);
		}
	}
}*/
int main(){
	cin>>n>>k;
	REP(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	for(ll i=2;i<=sqrt(sum);i++){
		if(sum%i==0){
			pr_fa.push_back(i);
			if(i*i!=sum)
				pr_fa.push_back(sum/i);
		}
	}
	ll ans=1;
	pr_fa.push_back(sum);
	sort(pr_fa.begin(),pr_fa.end());
	for(ll i=0;i<pr_fa.size();i++){
		vector<ll> v1;
		v1.clear();
		//ll t1=pr_fa[i];
		ll sum1=0;
		for(ll j=0;j<n;j++){
			sum1+=(a[j]%pr_fa[i]);
			v1.push_back(a[j]%pr_fa[i]);
		}
		if(sum1%pr_fa[i]!=0){
			continue;
		}
		sort(v1.begin(),v1.end(),greater<ll>());
		sum1=sum1/pr_fa[i];
		ll tk=0;
		for(ll j=0;j<sum1;j++){
			tk+=pr_fa[i]-v1[j];
		}
		if(tk<=k)ans=pr_fa[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  string S;
  cin >> S;
  bool a[3] = {0};
  rep(i,3)
  {
    a[S[i]-'a'] ++ ;
  }
  if(all_of(a,a+3,[](auto x){return x;}))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
N,L = map(int,input().split())
A = list(map(int,input().split()))

last = -1
for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        last = i+1
        break
else:
    print('Impossible')
    exit()

print('Possible')
ans = [n for n in range(1,last)] + [n for n in range(N-1,last,-1)]
ans.append(last)
print(*ans, sep='\n')

Measured memory_bytes: 14052
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 201010;

// 組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] / (fac[k] * fac[n - k]);
}


ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>l(n);
	rep(i, n) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	ll ans = 0;
	rep(i, n) {
		for (ll j = i + 1;j < n;++j) {
			ll res= lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
			ll res2 = l.end() - upper_bound(l.begin(), l.end(), l[j] - l[i]);
			if (res == 0 || res2 == 0)continue;
			ans += max((ll)0, res + res2 - n);
			ans--;
			if (l[j] - l[i] < l[i])ans--;
		}
	}
	ans /= 3;
	cout << ans << endl;
	return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s, t;


// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s >> t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));

	if(s < t) cout<<"Yes";
	else cout<<"No";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 237952
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf pop_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

ll power(ll a, ll b){
    if(!b){
        return 1;
    }
    if(b&1){
        return (a * power(a*a , b/2));
    }
    return power(a*a , b/2);
}


signed main(){ 
    IOS
    //io_set();
    ll n, m, k;
    cin >> n >> m;
    vector < ll > v[n];
    rep(i, m){
        cin >> k;
        v[i].resize(k);
        rep(j, k){
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    ll p[m];
    k = 0;
    rep(i, m)   cin >> p[i];
    rep(i, (1<<n)){
        bool ok = true;
        rep(j, m){
            ll c = 0;
            for(auto it : v[j]){
                if((1<<it)&i){
                    c++;
                }
            }
            if(c%2 != p[j]){
                ok = false;
            }
        }
        if(ok){
            k++;
        }
    }
    cout << k << endl;
    return 0;
}



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

int main() {
  int N;
  cin >>N;
  
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum+=p.at(i);
  }
  sum+=p.at(N-1)/2;
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n;
int abs(int x)
{
	if(x<0)  return -x;
	return x;
}
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		int t,x,y;
		scanf("%d %d %d",&t,&x,&y);
		if(x<0)  x=-x;
		if(y<0)  y=-y;
		if((x+y)%2!=(t%2)||(x+y>t)){printf("No");return 0;}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

vector<ll> divisors_count(ll a){
    vector<ll> res(a+1, 0);

    for(ll i = 1; i <= a; i++){
        for(ll j = 1; i * j <= a; j++) res[i*j]++;
    }

    return res;
}

int main(){
    int N; cin >> N;
    
    ll ans = 0;
    vector<ll> d_counter = divisors_count(N);
    for (int i = 1; i <= N; i++){
        ans += i*d_counter[i];
    }

    cout << ans << endl;
}

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

int main()
{
    std::string s;
    std::cin >> s;
    int sizeS = s.size();
    int counter = 0;
    for(int i = 0; i < sizeS-1; i++){
        if(s[i] != s[i+1]) 
            counter++;
    }
    std::cout << counter << std::endl;
    return 0;
}


Measured memory_bytes: 512
a,b=map(int,input().split())
l=(a+3)//4*4
r=b//4*4
x=[]
for i in range(a,l):x.append(i)
for i in range(r,b+1):x.append(i)
while len(x)>1:x.append(x.pop()^x.pop())
print(x[0])

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,r) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  MAP mp;
  vll a(2 * n - 1, 0);
  if (n == 2) {
	if (m == 2) {
	  cout << "Yes" << endl;
	  rep(i, 3) cout << i + 1 << endl;
	}
	else cout << "No" << endl;
	return 0;
  }
  if (m == 2 * n - 1 || m == 1) {
	cout << "No" << endl;
	return 0;
  }

  if (m == 2 * n - 2) {
	a[n - 2] = m - 1; mp[m - 1]++;
	a[n - 1] = m; mp[m]++;
	a[n] = m + 1; mp[m + 1]++;
	a[n + 1] = m - 2; mp[m - 2]++;
  }
  else {
	a[n - 2] = m + 1; mp[m + 1]++;
	a[n - 1] = m; mp[m]++;
	a[n] = m - 1; mp[m - 1]++;
	a[n + 1] = m + 2; mp[m + 2]++;
  }

  rep(i, 2 * n - 1) {
	if (i >= n - 2 && i <= n + 1) continue;
	cnt++;
	if (cnt == m - 1) cnt = m + 3;
	a[i] = cnt;
  }

  cout << "Yes" << endl;
  rep(i, 2 * n - 1) cout << a[i] << endl;

  return 0;
}

Measured memory_bytes: 3072
use std::io::Read;
use std::f64::consts::PI;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let r: usize = iterator.next().unwrap().parse().unwrap();

    let ans: f64 = 2_f64 * (r as f64) * PI;

    return format!("{:.3}", ans);
}


Measured memory_bytes: 2148
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			System.out.println(format(parse(sc.next()) + parse(sc.next())));
		}
	}

	static int parse(String s) {
		int ret = 0;
		int d = 1;
		for (char c : s.toCharArray()) {
			if ('2' <= c && c <= '9') {
				d = c - '0';
			} else {
				if (c == 'm') {
					ret += d * 1000;
				} else if (c == 'c') {
					ret += d * 100;
				} else if (c == 'x') {
					ret += d * 10;
				} else if (c == 'i') {
					ret += d;
				}
				d = 1;
			}
		}
		return ret;
	}

	static String format(int v) {
		String ret = digit(v, 1000, 'm');
		v %= 1000;
		ret += digit(v, 100, 'c');
		v %= 100;
		ret += digit(v, 10, 'x');
		v %= 10;
		ret += digit(v, 1, 'i');
		return ret;
	}

	static String digit(int v, int div, char c) {
		int count = v / div;
		if (count == 0) {
			return "";
		} else if (count == 1) {
			return c + "";
		} else {
			return "" + count + c;
		}
	}

}

Measured memory_bytes: 27080
'use strict';
(function(input){
  input=input.trim().split(/\n/);
  const s=input[0];
  const S=s.length;
  const t=input[1];
  const T=t.length;
  const dp=new Array(S+1).fill('場所取り').map(x=>new Array(T+1).fill(0));
  //console.log(dp);
  for(let i=0;i<S;i++){
    for(let j=0;j<T;j++){
      let cs=s[i];
      let ct=t[j];
      if(cs===ct){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=Math.max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  //console.log(dp);
  var ans='';
  var I=S,J=T;
  while(I>0&&J>0){
    //console.log(I,J);
    if(dp[I][J]===dp[I][J-1])
      J--;
    else if(dp[I][J]===dp[I-1][J])
      I--;
    else{
      ans=s[I-1]+ans;
      I--;
      J--;
    }
  }
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 251276
#include<bits/stdc++.h>
using namespace std;
#define re register
#define in inline
#define ll long long
#define get getchar()
in ll read()
{
	ll t=0, x=1; char ch=get;
	while((ch<'0'||ch>'9')&&ch!='-')ch=get;
	if(ch=='-')ch=get,x=-1;
	while(ch>='0'&&ch<='9')t=t*10+ch-'0',ch=get;
	return t*x;
}
int tot,sum[1001];
int main()
{
	int a=read(),b=read(),k=read();
	for(re int i=min(a,b);i;i--)
	{
		if(a%i==0&&b%i==0)
			sum[++tot]=i;
	}
	cout<<sum[k]<<endl;return 0;
}


Measured memory_bytes: 256
n = int(input())
class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right
dali = [0] * n
def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[node] = BiTree(node, left, right)
def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
            return dali[i].parent
    dali[i].parent = -1

    return dali[i].parent
def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1
    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1 
    return max(h1, h2)
def getDegree(i):
    if dali[i].right == -1 and dali[i].left == -1:
        dali[i].deg = 0
    elif dali[i].right == -1 :
        dali[i].deg = 1
    elif dali[i].left == -1:
        dali[i].deg = 1
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"
def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]
for j in range(n):
    inputdata(j)
for j in range(n):
    getParent(dali[j].node)
for j in range(n):
    getDepth(dali[j].node)
h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(dali[j].node)
    h1 = 0
    h2 = 0
for j in range(n):
    getDegree(dali[j].node)
for j in range(n):
    getType(dali[j].node)
for j in range(n):
    getSibling(dali[j].node)
for j in range((dali[j].node)+1):
    print("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" % (dali[j].node, dali[j].parent, dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))



Measured memory_bytes: 5632
#include <stdio.h>

#define MOD 1000000007
long long powmod(long long b,int e)
{
    if (e==0) return 1;
    if (e&1) return powmod(b*b%MOD,e/2)*b%MOD;
    return powmod(b*b%MOD,e/2);
}
long long inv[200005];

long long fac[200005];
long long ifac[200005];
long long choose(int a,int b)
{
    if (b<0 || b>a) return 0;
    return (fac[a]*ifac[b]%MOD)*ifac[a-b]%MOD;
}

int n,a,b,c;
long long ans=0;
long long tmp;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    for (int i=1; i<=200000; i++) inv[i]=powmod(i,MOD-2);
    fac[0]=ifac[0]=1;
    for (int i=1; i<=200000; i++) {
        fac[i]=fac[i-1]*i%MOD;
        ifac[i]=ifac[i-1]*inv[i]%MOD;
    }
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for (int i=0; i<n; i++) {
        // play to (n-1,i) then A wins
        tmp=powmod(inv[a+b],n+i); tmp%=MOD;
        tmp*=powmod(a,n); tmp%=MOD;
        tmp*=powmod(b,i); tmp%=MOD;
        tmp*=choose(n+i-1,i); tmp%=MOD;
        //printf("got %d^%d %d^%d = %lld\n",a,n,b,i,tmp);
        ans+=tmp*(n+i); ans%=MOD;
        // play to (i,n-1) then B wins
        tmp=powmod(inv[a+b],n+i); tmp%=MOD;
        tmp*=powmod(b,n); tmp%=MOD;
        tmp*=powmod(a,i); tmp%=MOD;
        tmp*=choose(n+i-1,i); tmp%=MOD;
        ans+=tmp*(n+i); ans%=MOD;
    }
    // consider c
    // ans becomes ans*100/(100-c)
    ans*=100; ans%=MOD;
    ans*=inv[100-c]; ans%=MOD;
    printf("%lld\n",ans);
}


Measured memory_bytes: 4864