akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
priority_queue<P> a, b;
map<int, int> m1, m2;
P p1[2], p2[2];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin >> n;
  set<int> s;
  FOR(i,0,n) {
    int v;cin >> v;
    s.insert(v);
    if(i % 2) {
      m1[v]++;
    } else {
      m2[v]++;
    }
  }
  if(s.size() == 1) {
    cout << n / 2 << endl;
    return 0;
  }
  for(auto x : m1) {
    a.push(P(x.second, x.first));
  }
  for(auto x : m2) {
    b.push(P(x.second, x.first));
  }
  p1[0] = a.top();a.pop();
  if(!a.empty()) {
    p1[1] = a.top();a.pop();
  } else {
    p1[1] = P(n, n/2);
  }
  p2[0] = b.top();b.pop();
  if(!b.empty()) {
    p2[1] = b.top();b.pop();
  } else {
    p2[1] = P(n, n/2);
  }

  if(p1[0].second != p2[0].second) {
    cout << n - p1[0].first - p2[0].first << endl;
  } else {
    cout << min(n - p1[1].first - p2[0].first, n - p1[0].first - p2[1].first) << endl;
  }
  return 0;
}

Measured memory_bytes: 10744
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int cou, k;
int mp[20];

void output(int pla){
	REP(i, pla)cout << mp[i];cout << endl;
}

bool dfs(int now, int keta, int pla){
	mp[pla] = now;
	if(keta == 0){
		cou++;
		if(cou == k){
			output(pla+1);
			return true;
		}
		return false;
	}
	if(now > 0)if(dfs(now-1, keta-1, pla+1))return true;
	if(dfs(now, keta-1, pla+1))return true;
	if(now < 9)if(dfs(now+1, keta-1, pla+1))return true;
	return false;
}

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

	cin >> k;
	for(int i = 0;i < 12;i++){
		for(int j = 1;j < 10;j++){
			if(dfs(j, i, 0))return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    int count[3] = {};
    for(int i = 0;i < s.size();i++)
    {
        count[s[i] - 'a']++;
    }
    if(fabs(count[0] - count [1]) >= 2 || fabs(count[0] - count [2]) >= 2 || fabs(count[1] - count [2]) >= 2)
    {
        cout << "NO\n";
    }
    else
    {
        cout << "YES\n";
    }
    
    return 0;
}

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

int main () {
    long long A, B;
    int cnt = 1, last_a = 1, last_b = 1;
    cin >> A >> B;
    int div_a[(int)log2(A)+1], div_b[(int)log2(B)+1];
    div_a[0] = div_b[0] = 1;

    long long na = A;
    for (int i = 2; i < sqrt(na) + 1; i++) {
        while(na % i == 0) {
            if (div_a[last_a - 1] != i) {
                div_a[last_a] = i;
                last_a++;
            }
            na /= i;
        }
    }
    if (na != 1) {
        div_a[last_a] = na;
        last_a++;
    }

    long long nb = B;
    for (int i = 2; i < sqrt(nb) + 1; i++) {
        while(nb % i == 0) {
            if (div_b[last_b - 1] != i) {
                div_b[last_b] = i;
                last_b++;
            }
            nb /= i;
        }
    }
    if (nb != 1) {
        div_b[last_b] = nb;
        last_b++;
    }

    for (int i = 1; i < last_a; i++) {
        for (int j = 1; j < last_b; j++) {
            if (div_a[i] == div_b[j]) {cnt++;}
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  ans = 0
  for b in range(k+1, n+1):
    ans += (b-k) * (n//b) + max(n%b - (max(k-1, 0)), 0)
  print(ans)
  

if __name__=='__main__':
  main()



Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long double ld;
using namespace std;
int main(void){
  ld a,b,x; cin>>a>>b>>x; x/=a;
  ld dig;
  if((x*2)==(a*b)){ printf("%.10llf\n",(long double)45); return 0;}
  else if(x*2<a*b){
    a=2*x/b;
    ld c=sqrtl(a*a+b*b);
    dig=asin(b/c);
  }else{
    b=2*(a*b-x)/a;
    ld c=sqrtl(a*a+b*b);
    dig=acos(a/c);
  }
  printf("%.10llf\n",dig*180/M_PI);
  return 0;
}

Measured memory_bytes: 3684
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var n = cin.ReadInt;
            var A = cin.ReadIntArray(n);
            var piv = Partition(A, 0, n - 1);
            var Res = A.Select((x, i) => i == piv ? string.Format("[{0}]", x) : x.ToString()).ToArray().Join();
            Console.WriteLine(Res);
        }
        int Partition(int[] A, int p, int r) {
            var x = A[r];
            var i = p - 1;
            for(int j = p; j < r; j++) {
                if(A[j] <= x) {
                    A.Swap(++i, j);
                }
            }
            A.Swap(i + 1, r);
            return i + 1;
        }
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}



Measured memory_bytes: 32156
#include<bits/stdc++.h>
#define re register
using namespace std;
int n,ans[200002],c[200002],l[200002],r[200002];
inline void add(re int x){for(;x<=n;x+=x&(-x))++c[x];}
inline int ask(re int x){
	re int sum=0;
	for(;x;x-=x&(-x))sum+=c[x];
	return sum;
}
struct node{
	int x,y,id;
	bool operator <(const node &a){
		return x<a.x;
	}
}p[200002];
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int fa[200002],siz[200002],stk[200002],tp,mx[200002];
inline int root(re int x){return x==fa[x]?x:fa[x]=root(fa[x]);}
inline void merge(re int x,re int y){
	if((x=root(x))==(y=root(y)))return;
	if(siz[x]>siz[y])x^=y^=x^=y;
	fa[x]=y,siz[y]+=siz[x];mx[y]=min(mx[y],mx[x]);
}
int main(){
	n=read();
	for(re int i=1;i<=n;++i)p[i].x=read(),p[i].y=read(),p[i].id=i,fa[i]=i,siz[i]=1;
	sort(p+1,p+n+1);
	for(re int i=1;i<=n;++i){mx[p[i].id]=p[i].y;
		while(tp&&p[i].y>mx[root(p[stk[tp]].id)])merge(p[i].id,p[stk[tp]].id),--tp;
		stk[++tp]=i;
	}
	for(re int i=1;i<=n;++i)printf("%d\n",siz[root(i)]);
}

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

using namespace std;

char cnt (vector<string> board, int h, int w) {
    int way_h[] = {-1, -1, 0, 1, 1, 1, 0, -1};
    int way_w[] = {0, 1, 1, 1, 0, -1, -1, -1};

    int cnt = 0;
    for (int i = 0; i < 8; i++) {
        if (h+way_h[i] < 0 || board.size() <= h+way_h[i] || w+way_w[i] < 0 || board[0].size() <= w+way_w[i]) {
            continue;
        }
        if (board[h+way_h[i]][w+way_w[i]] == '#') {
            cnt++;
        }
    }

    return cnt+'0';
}

int main(int argc, char* argv[])
{
    int H, W; cin >> H >> W;

    vector<string> board(H);
    for (int i = 0; i < H; i++) {
        cin >> board[i];
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (board[i][j] != '#') {
	      board[i][j] = cnt(board, i, j);
            }
        }
        cout << board[i] << endl;
    }

    return 0;
}


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

const int MAXN = 2e5 + 5;

int H, W, N;
int x, y;
char s[MAXN], t[MAXN];

void load() {
	scanf("%d%d%d%d%d", &H, &W, &N, &x, &y);
	scanf("%s%s", s, t);
}

bool in_range(int val, int lo, int hi) {
	return val >= lo && val <= hi;
}

void up(int &ref, int val) {
	if (ref < val)
		ref = val;
}

void down(int &ref, int val) {
	if (ref > val)
		ref = val;
}

bool solve() {
	int lox = 1, hix = H;
	int loy = 1, hiy = W;
	for (int i = N - 1; i >= 0; i--) {
		if (t[i] == 'L')
			hiy++;
		else if (t[i] == 'R')
			loy--;
		else if (t[i] == 'U')
			hix++;
		else
			lox--;
		up(lox, 1);
		up(loy, 1);
		down(hix, H);
		down(hiy, W);
		if (s[i] == 'L')
			loy++;
		else if (s[i] == 'R')
			hiy--;
		else if (s[i] == 'U')
			lox++;
		else
			hix--;
		up(lox, 1);
		up(loy, 1);
		down(hix, H);
		down(hiy, W);
		if (lox > hix || loy > hiy)
			return false;
	}
	return in_range(x, lox, hix) && in_range(y, loy, hiy);
}

int main() {
	load();
	puts(solve() ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


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


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}




int main() {
    
    ll N = lin(); ll K = lin();
    
    ll kbitnum = 0;
    
    auto temp = K;
    
    while(temp != 0){
        
        kbitnum++;
        temp/=2;
        
    }

    
    vector<ll> A;
    vector<ll> reducedA;
    vector<ll> upperA;
    ll tempA;
    ll ans = 0;
    for(auto i = 0; i<N; i++){
        
        cin >> tempA;
        A.push_back(tempA);
        upperA.push_back(tempA& (~((1LL<<(kbitnum))-1)));
        reducedA.push_back(tempA & ((1LL<<(kbitnum+1))-1));
        
        ans += upperA.back();
    }
    
    /// 0の数を数えて処理する。高々40桁なので、Nについて愚直にループを回す。
    
    ll count1[kbitnum+1];
    
    for(auto i = 0; i<=kbitnum;i++){
        count1[i] = 0;
    }
    
    for(auto a:reducedA){
        auto x = a;
        auto dig = 0;
        while(x != 0){
            
            if (x%2 == 1){
                count1[dig]++;
            }
            dig++;
            x/=2;
        }
        
    }

    
    
    ll compK = 0;
    for(auto j = kbitnum-1; j>=0; j--){
        
        if (count1[j] <= N-count1[j]){ ///bitを立てたほうが得。
            
            if (compK + (1LL<<j) <= K){
                compK += 1LL<<j;
                
                ans += ((N-count1[j])* (1LL<<j));
                
            }else{
                ans+=( count1[j]  * (1LL<<j));
            }
            
        }else{
                ans+=( count1[j] * (1LL<<j));
        }
    }
    
    
    cout << ans << endl;
    
    
    return 0;
}




Measured memory_bytes: 2912
import itertools
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
ks = []
for i in range(M):
    ks.append(inpl())
p = inpl()

ans = 0
for s in itertools.product(range(2),repeat=N):
    for i in range(M):
        if (sum([ s[n-1] for n in ks[i][1:]]) - p[i]) % 2:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 42992
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n,k=l_in()

s = set(range(n))

for _ in range(k):
    d = n_in()
    A = l_in()
    for a in A:
        if a-1 in s:
            s.remove(a-1)

print(len(s))


Measured memory_bytes: 67688
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e6+5,L=1e6;
bitset<N>vis;int p[N],mu[N],cnt[N],a[N],st[N],c[N],s[N],top,n,m,res;
void init(int n=L){
	mu[1]=1;
	fp(i,2,n){
		if(!vis[i])p[++m]=i,mu[i]=-1;
		for(R int j=1;j<=m&&i*p[j]<=n;++j){
			vis[i*p[j]]=1;
			if(i%p[j]==0)break;
			mu[i*p[j]]=-mu[i];
		}
	}
	fp(i,1,n)upd(mu[i],P);
	fp(i,1,n)for(R int j=i;j<=n;j+=i)upd(s[j],mul(i,mu[i]));
}
int main(){
	scanf("%d",&n);
	init();
	fp(i,1,n)scanf("%d",&a[i]),++cnt[a[i]];
	fp(T,1,L){
		R int sum=0;
		for(R int j=T;j<=L;j+=T)upd(sum,mul(j/T,cnt[j]));
		sum=mul(sum,sum),sum=mul(sum,mul(T,s[T]));
		upd(res,sum);
	}
	fp(i,1,n)res=dec(res,a[i]);
	res=mul(res,(P+1)>>1);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 18816
import java.util.Scanner;

public class Main {

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

		int n = S.length();
		int[] ten = new int[n + 1];
		ten[0] = 1;
		for(int i = 1; i < ten.length; i++) {
			ten[i] = (ten[i - 1] * 10) % 2019;
		}
		int[] sum = new int[n + 1];
		sum[0] = 0;
		for(int i = 1; i <= n; i++) {
			sum[i] = (sum[i - 1] + Integer.parseInt(S.substring(n-i,n-i+1)) * ten[i-1]) % 2019;
		}

		int[] count = new int[2019];
		for(int i = 0; i <= n; i++) {
			int res = sum[i] % 2019;
			count[res] ++;
		}
		int ans = 0;
        for (int i = 0; i < count.length; i++) {
            ans += count[i]*(count[i]-1)/2;
        }
        System.out.println(ans);
	}
}


Measured memory_bytes: 51616
N = int(input())
S = str(input())

AL = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

outputString = ""
for count in range(len(S)):
    add = AL.index(S[count])
    if add +N > 25:
        outputString = outputString + AL[add-26+N]
    else:
        outputString = outputString + AL[add+N]
print(outputString)

Measured memory_bytes: 3064
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0])
dist = []
for i in range(n):
    dist.append(abs(a[i+1] - a[i]))
for i in range(len(dist)):
    if dist[i] > k/2:
        dist[i] = k - dist[i]

print(sum(dist) - max(dist))

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

int main(){
  ll N,X,Y;
  ll NMAX = 2.0e3;
  cin >> N >> X >> Y;
  vector<ll> cnt(N);
  
  for(ll i=1;i<N+1;i++){
    for(ll j=i+1;j<N+1;j++){
      ll a,b,c;
      a = abs(j-i);
      b = abs(X-i) + 1 + abs(Y-j);
      c = abs(Y-i) + 1 + abs(X-j);
      cnt.at(min({a,b,c}))++;
    }
  }
  
  for(ll i=1;i<N;i++){
    cout << cnt.at(i) << endl;
  }
  
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

const int M=2005;
int l[M];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&l[i]);
	sort(l,l+n);
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			ans+=lower_bound(l+j+1,l+n,l[i]+l[j])-l-j-1;
	printf("%d\n",ans);
}

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


using namespace std;

int n,k;
int d[100];
int inf = 1111111111;
//struct edge{int to,cost; };

vector<pair<int,int> > g[100];

void solve(int s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  fill(d,d+n,inf);
  d[s] = 0;
  que.push(make_pair(0,s));

  while(!que.empty()){
    pair<int,int> p = que.top();
    que.pop();
    int v = p.second;
    if(d[v]<p.first)continue;
    for(int i = 0;i<g[v].size();i++){
      pair<int,int> e = g[v][i];
      if(d[e.first] > d[v]+e.second){
	d[e.first] = d[v] + e.second;
	//cout<<e.first<<"\t"<<e.second<<endl;
	que.push(make_pair(d[e.first],e.first));
      }
    }
  }
  
}

int main(){
  while(cin>>n>>k){
    if(n == 0&&k==0)
      break;
    memset(g,0,sizeof(g));
    for(int i = 0;i<k;i++){
      int f;
      cin>>f;
      if(f==0){
	int a,b;
	cin>>a>>b;
	a--;b--;
	//memset(d,-1,sizeof(d));
	//dijkstra
	//cout<<"ab:"<<a<<"\t"<<b<<endl;
	solve(a);
	if(d[b] == inf)
	  cout<<"-1"<<endl;
	else
	  cout<<d[b]<<endl;

      }else{
	int c,d,e;
	cin>>c>>d>>e;
	c--;d--;
	//regist
	//cout<<"reg"<<endl;
	g[c].push_back(make_pair(d,e));
	g[d].push_back(make_pair(c,e));
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
 
using namespace std;
 
unsigned long long clp(unsigned long long x)
{
    x -= 1;
    x = x | (x >>  1);
    x = x | (x >>  2);
    x = x | (x >>  4);
    x = x | (x >>  8);
    x = x | (x >> 16);
    x = x | (x >> 32);
    return x + 1;
}
 
// a[0], a[1], ... , a[n - 1] is a given array of length n.
// T is the type of elements of array a.
// UNIT is a element such that for any element x, f(x, UNIT) == x.
// e.g. f(x, y) = sum(x, y), UNIT = 0.
// e.g. f(x, y) = min(x, y), UNIT = INFINITY.
template <class T>
class segment_tree
{
    private:
        size_t n;
        const T UNIT;
        const function<T(T, T)> f;
        T *a;
    public:
        segment_tree(size_t size, T UNIT, function<T(T, T)> f) : n(clp(size)), UNIT(UNIT), f(f)
        {
            a = new T[2 * n - 1];
            fill(a, a + 2 * n - 1, UNIT);
        }
        ~segment_tree() {
            delete [] a;
        }
        void update(size_t i, T x)
        {
            i += n - 1;
            a[i] += x;
            while (i) {
                i = (i - 1) / 2;
                a[i] = f(a[2 * i + 1], a[2 * i + 2]);
            }
        }
        T query(size_t query_first, size_t query_last, size_t k = 0, size_t node_first = 0, size_t node_last = 0)
        {
            if (k == 0) {
                node_last = n;
            }
            if (node_last <= query_first || query_last <= node_first) {
                return UNIT;
            }
            if (query_first <= node_first && node_last <= query_last) {
                return a[k];
            } else {
                size_t node_mid = (node_first + node_last) / 2;
                T vl = query(query_first, query_last, k * 2 + 1, node_first, node_mid);
                T vr = query(query_first, query_last, k * 2 + 2, node_mid, node_last);
                return f(vl, vr);
            }
        }
};
 
template <class T>
class range_add_query
{
    private:
        segment_tree<T> *t;
    public:
        range_add_query(size_t size) {
            t = new segment_tree<T>(size + 1, 0, [](int x, int y) {return x + y;});
        }
        ~range_add_query() {
            delete t;
        }
        void range_add(size_t first, size_t last, T x) {
            t->update(first, x);
            t->update(last, -x);
        }
        T get(size_t i) {
            return t->query(0, i + 1);
        }
};

int main(void)
{
    int n, q;
    cin >> n >> q;
    range_add_query<int> t(n);
    while (q--) {
        int com;
        cin >> com;
        if (com == 0) {
            int first, last, x;
            cin >> first >> last >> x;
            first--;
            t.range_add(first, last, x);
        } else if (com == 1) {
            int i;
            cin >> i;
            i--;
            cout << t.get(i) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3812
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

//dp[i][j] 先頭i桁目まで使った数を13で割ったときに余りがjである数の総数
unsigned long long int dp[100001][13];

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

    n = s.size();

    dp[0][0] = 1;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == '?')
        {
            c = -1;
        }
        else
        {
            c = s[i] - '0';
        }

        //?に数字をいれる
        for (int j = 0; j < 10; j++)
        {
            //数字が固定されてる場合,その数以外はスキップ
            if (c != -1 && c != j)
            {
                continue;
            }

            //dp[i][j]のjについてループ
            for (int k = 0; k < 13; k++)
            {
                //更新
                //i桁目までを使ったときの余りは k
                dp[i + 1][(10 * k + j) % 13] += dp[i][k];
            }
        }

        for (int j = 0; j < 13; j++)
        {
            dp[i + 1][j] = dp[i + 1][j] % MOD;
        }
    }

    cout << dp[n][5];
    return 0;
}

Measured memory_bytes: 10624
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] l = new int[N];
        int ans = 0;
        
        for(int i = 0; i < N; i++) l[i] = sc.nextInt();
        Arrays.sort(l);
        for(int i = 0; i < K; i++) ans += l[(N - 1) - i];

        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(std::string T);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    std::string T;
    std::cin >> T;
    solve(T);
}

void solve(std::string T){
    REP(i, T.length()){
        if(T[i] == '?'){
            T[i] = 'D';
        }
    }
    cout << T << el;
}



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

int main(){
    ll h, w, out;
    cin >> h >> w;
    if (min(h, w) == 1) out = 1;
    else out = (h * w + 1) / 2; 
    cout << out << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int p,q,r;
  vector<int> a(3);
  rep(i,3){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout << a.at(0) + a.at(1) << endl;
  }


Measured memory_bytes: 256
n,m=map(int,input().split())
N=3*n
d=[[0]*(N+1) for i in range(N+4)]
d[0][0]=1
for i in range(N):
  a,b,c,e=d[i:i+4]
  for j in range(N):J=j+1;b[j]=(b[j]+a[j])%m;c[J]=(c[J]+a[j]*(i+1))%m;e[J]=(e[J]+a[j]*(i+1)*(i+2))%m
print(sum(d[N][:n+1])%m)


Measured memory_bytes: 315784
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=110000;
int n,a[N],ans;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        if(i+1>a[i+1]) {
            for(int j=i+1;a[j]==i;j++)
                ans^=1;
            ans|=(a[i]-i)&1;
            puts(ans? "First":"Second");
            return 0;
        }
}

Measured memory_bytes: 640
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

#define MAX_H 264
#define parent(i) ((i)/2)
#define left(i) ((i)*2)
#define right(i) ((i)*2+1)

int H;
int heap[MAX_H];
#define len heap[0]

void insert(int x) {
	heap[++len] = x;
}

void print_node(int i) {
	printf("node %d: key = %d, ", i, heap[i]);
	if (0 < parent(i)) printf("parent key = %d, ", heap[parent(i)]);
	if (left(i) <= len) printf("left key = %d, ", heap[left(i)]);
	if (right(i) <= len) printf("right key = %d, ", heap[right(i)]);
	puts("");
}

int main(int argc, char **argv)
{
	int i, x;
	scanf("%d", &H);
	for (i = 0; i < H; i++) {
		scanf("%d", &x);
		insert(x);
	}

	for (i = 1; i <= H; i++) {
		print_node(i);
	}

	return 0;
}

Measured memory_bytes: 608
n=int(input())
a=list(map(int,input().split()))
r=1
mx=10**18
if 0 in a:
  print(0)
  exit()
for ii in range(len(a)):
  r*=a[ii]
  #print(r)
  if r>mx:
    print(-1)
    exit()
print(r)
       

Measured memory_bytes: 21708
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    ll n, t;
    cin >> n >> t;
    ll a[3010], b[3010];
    rep(i, n) cin >> a[i] >> b[i];
    ll dp_l[3010][3010] = {}, dp_r[3010][3010] = {};
    //0～i-1の料理から選んでj分で食べるときの満足度の最大値
    //i+1～n

    rep(i, n) {

        rep(j, t) {
            //食べない
            dp_l[i + 1][j] = max(dp_l[i + 1][j], dp_l[i][j]);
            //食べる
            if (j + a[i] >= t) continue;
            dp_l[i + 1][j + a[i]] = max(dp_l[i + 1][j + a[i]], dp_l[i][j] + b[i]);
        }
    }

    for (int i = n; i >= 1; i--) {

        rep(j, t) {
            //食べない
            dp_r[i - 1][j] = max(dp_r[i - 1][j], dp_r[i][j]);
            //食べる
            if (j + a[i] >= t) continue;
            dp_r[i - 1][j + a[i]] = max(dp_r[i - 1][j + a[i]], dp_r[i][j] + b[i]);
        }
    }

    ll ans = 0;

    rep(last, n) {
        ll Max = 0;

        rep(j, t) {
            Max = max(Max, dp_l[last][j] + dp_r[last][(t - 1) - j] + b[last]);
        }
        ans = max(ans, Max);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 141824
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	int n; 

	cout << fixed << setprecision(4);

	while(cin >> n && n) {
		double s=0.0, s2=0.0, x;
		int n0 = n;

		while(n0-- && cin >> x) {
			s += x;
			s2 += x*x;
		}
		
		s /= n;
		s2 /= n;
		cout << sqrt(s2 - s*s) << '\n';
	}
	
	return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H, W;
	char A;
	scanf("%d %d", &H, &W);
	int cnt = 0;
	while(scanf("%c", &A) != EOF){
		if(A == '#') cnt++;
	}
	if(cnt == H + W - 1) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}


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

int main() {
  int H, W;
  char temp;
  
  
  cin >> H >> W;
  vector<char> characters(H * W);
  // vector<char> outputs((H + 2) * (W + 2));
  for (int i = 0; i < H*W; i++) {
    cin >> characters.at(i);
  }
  
  for (int i = 0; i < H*W; i++) {
    // cout << characters.at(i);
  }
  // cout << endl;
  
  int counter = 0;
  
  for (int h = 0; h < H+2; h++) {
    for (int w = 0; w < W+2; w++) {
      // cout << h << w;
      if ((h == 0 || h == H+1) && w != W+1) {
        cout << '#';
      }
      else if (w == 0 || w == W+1) {
        cout << '#';
        if (w == W+1) {
          cout << endl;
        }
      }
      // else if (w == W) {
      //   cout << '#' << endl;
      // }
      else {
        cout << characters.at(counter);
        counter++;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int d,w;
int maze[15][15];
int main(){
    while(1){
        int d,w;
        cin>>d>>w;
        if(d==0 && w==0) break;
        for(int i=0;i<d;i++){
            for(int j=0;j<w;j++) cin>>maze[i][j];
        }
        int max=0;
        for(int i=1;i<d-1;i++){
            for(int j=1;j<w-1;j++){
                for(int k=i;k<d-1;k++){
                    for(int l=j;l<w-1;l++){
                        int min=inf;
                        for(int m=i-1;m<=k+1;m++){
                            if(maze[m][j-1]<min) min=maze[m][j-1];
                            if(maze[m][l+1]<min) min=maze[m][l+1];
                        }
                        for(int n=j-1;n<=l+1;n++){
                            if(maze[i-1][n]<min) min=maze[i-1][n];
                            if(maze[k+1][n]<min) min=maze[k+1][n];
                        }
                        //周囲のminが求まる.
                        bool ok=true;
                        int cnt=0;
                        for(int m=j;m<=l;m++){
                            for(int n=i;n<=k;n++){
                                if(maze[n][m]>=min) ok=false;
                                else cnt+=min-maze[n][m];
                            }
                        }
                        //cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<ok<<endl;
                        //cout<<cnt<<" "<<min<<endl;
                        if(ok && cnt>=max) {
                            max=cnt;
                            //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                        }
                    }
                }
            }
        }
        cout<<max<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

LIMIT = 10**18

if 0 in set(As):
    print(0)
else:
    result = 1
    for a in As:
        result *= a
        if result > LIMIT:
            result = -1
            break
    
    print(result)


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

int main(){
	int n; string s;
  	cin >> n >> s;
  	if(s.length() <= n) cout << s;
  	else{
    	for(int i=0;i<n;++i) cout << s[i];
      	cout << "...";
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<vector>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int cmp(int a,int b){
	return a>b;
}
ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return w*x;
}//快读算法
ll gcd(ll a, ll b)
{
    return b? gcd(b, a % b): a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main(){
    ll a,b;
    cin>>a>>b;
    ll num;
    num=lcm(a,b);
    cout<<num<<endl;
    return 0;
}




//humuhumunukunuku
//humuhumunukunuku



Measured memory_bytes: 256
n, m = map(int, input().strip().split(" "))
a = list(map(int, input().strip().split(" ")))
# print(n, m)
# print(a)
s = sum(a)
# print(s / 4 / m)

count = 0
for c in a:
    if c >= s / 4 / m:
        count+=1
# print(count, m)
if count >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
H = []
for cx in range(0,101):
    for cy in range(0,101):
        hantei = False
        for i in range(n):
            if xyh[i][2] > 0:
                if not H:
                    H.append(xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]))
                else:
                    hantei = True
                    if xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]) != H[0]:
                        H.pop(0)
                        break
        else:
            if hantei: 
                print(cx,cy,H[0])
                exit()
else:
    mx = 0
    for i in range(n):
        if mx < xyh[i][2]:
            ansind = i
            mx = xyh[i][2]
    print(xyh[ansind][0],xyh[ansind][1],xyh[ansind][2])


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

using namespace std;
using ll = long long;
#define MOD 1e9+7

int main(){
    int N;cin >> N;
    vector<pair<int, int>> vec;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        vec.push_back({b, i});
    }
    sort(vec.begin(), vec.end());
    for(int i = 0;i < N;i++){
        cout<<vec.at(i).second+1<<" ";
    }
    cout<<endl;
}


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

namespace Test01
{   
    class Program
    {      
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = input[0];
            int K = input[1];
            string S = Console.ReadLine();

            int cnt_hap = 0;
            int cnt_rl = 0;              
            for(int i = 1; i < N; i++)
            {
                if (S[i] == S[i - 1]) cnt_hap++;
                if (S[i - 1] == 'R' && S[i] == 'L') cnt_rl++;
            }
                       
            Console.WriteLine(Math.Min(cnt_hap + 2 * K, N - 1));
        }
    }
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;

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

	int n; cin >> n;
	vi a(n);

	for (int i=0;i<n;i++)
		cin >> a[i];
    
	int ans = 0;

	for (int i=0;i<n;i++)
	{
		while(a[i] % 2 == 0)
		{
			ans++;
			a[i] /= 2;
		}

	}

	cout << ans << "\n";


    return 0;
}


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

using namespace std;

const int maxn = 1e5+10;

int a[maxn], cor[maxn];

int suf[maxn];

bool mark[maxn];

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

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	multiset<int> st;

	for (int i = 1; i <= n; i++)
	{
		auto pos = st.lower_bound(a[i]);

		if (pos == st.begin()) st.insert(a[i]);
		else
		{
			st.erase(--pos);
			st.insert(a[i]);
		}
	}	

	printf("%d\n", st.size());
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define int long long

const int SZ = 1e5 + 5;
int n;
int a[2*SZ], b[2*SZ];

signed main()
{
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort (b, b+n);
	for (int i = 0; i < n; i++) {
		if (a[i] == b[n-1]) {
			cout << b[n-2] << endl;
		}
		else {
			cout << b[n-1] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4736
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <map>
#include <time.h>
#include <cstdlib>
#include <iomanip>
#include <array>

#pragma warning(disable:4996)

using namespace std;

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



int main(void) {
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		cout<<str[i];
		if (i == 3)cout << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(map(int,input().split()))
if (n%2==1 and a==[(i+1)//2*2 for i in range(n)]) or (n%2==0 and a==[i//2*2+1 for i in range(n)]):
    print(pow(2,n//2,10**9+7))
else:
    print(0)

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

int main() {
	string n;
  	cin >> n;
  
  	for(int i = 0; i < 3; i++) {
    	if(n.at(i) == '9') {
        	n.at(i) = '1';
        }else if(n.at(i) == '1') {
        	n.at(i) = '9';
        }
    }
  
  	cout << n << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/

int main(){
    string s,t;cin>>s>>t;
    s="#"+s;
    t="#"+t;//1-indexに直すため
    //dp[i][j]:sのi文字目までとtのj文字目までの共通部分列
    int n=(int)s.size()-1;
    int m=(int)t.size()-1;
    vector<vector<int>> dp(n+1,vector<int>(m+1));
    REP(i,n){
        REP(j,m){
            if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1;
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    //復元
    string ans="";
    int x=n;int y=m;
    while(x>0&&y>0){
        if(dp[x][y]==dp[x-1][y])x--;
        else if(dp[x][y]==dp[x][y-1])y--;
        else{
            ans=s[x]+ans;
            x--;y--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 35584
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a;
    b=(a/100)%10;
    c=(a/10)%10;
    d=a%10;
    if (b==d)
        cout<<"Yes";
        else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int NMX = 1e5;
vector<int> Graph[NMX];
int td[NMX],ad[NMX];
int n, u, v, ans;

void tbfs(int o,int k){
    for(auto v:Graph[k]){
        if(v == o) continue;
        td[v] = td[k]+1;
        tbfs(k,v);
    }
    return;
}

void abfs(int o,int k){
    for(auto v:Graph[k]){
        if(v == o) continue;
        ad[v] = ad[k]+1;
        abfs(k,v);
    }
    return;
}


signed main(){
    cin >> n >> u >> v; u--; v--;
    REP(i,n-1){
        int a, b; cin >> a >> b; a--; b--;
        Graph[a].eb(b);
        Graph[b].eb(a);
    }
    tbfs(-1,u);
    abfs(-1,v);
    REP(i,n){
        if(Graph[i].size()!=1 or td[i] > ad[i]) continue;
        chmax(ans,ad[i]-1);
    } 
    cout << ans <<'\n';
}

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

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

	for (int i = 0; i < s.size(); i++) {
		for (int j = i+1; j < s.size(); j++) {
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}

	cout << "yes" << endl;
	return 0;
}


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

int main()
{
	int a, b, result;
	string op;

	cin >> a >> op >> b;
	
	if (op == "+") {
		result = a + b;
	}
	else {
		result = a - b;
	}

	cout << result << endl;


	return 0;
}


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

using intBil7 = unsigned int;
class modBil7 {
private:
	static const intBil7 bil7 = 1000000007;
	static vector<intBil7> fact;
	static vector<intBil7> invfact;
public:
	intBil7 add(intBil7 a, intBil7 b) { return (a + b) % bil7; }
	intBil7 sub(intBil7 a, intBil7 b) { return (a + (bil7 - b)) % bil7; }
	intBil7 mul(intBil7 a, intBil7 b) { return (intBil7)((unsigned long long)a * (unsigned long long)b % (unsigned long long)bil7); }
	intBil7 div1(intBil7 b) {
		stack<pair<intBil7, pair<int, int>>> divbuf;
		intBil7 buf = bil7;
		while (b != 0) { divbuf.push(make_pair(buf / b, make_pair(buf, b))); buf %= b; swap(b, buf); }
		pair<int, int> m = make_pair(buf, buf);
		while (!divbuf.empty()) {
			m.second = sub(m.second, mul(m.first, divbuf.top().first));
			divbuf.pop(); swap(m.first, m.second);
		}
		return m.first;
	}
	intBil7 pow(intBil7 a, intBil7 b) {
		if (b == 0) return 1;
		return mul(
			mul(pow(a, b / 2), pow(a, b / 2)),
			(b & 1) ? a : 1
		);
	}
	intBil7 div(intBil7 a, intBil7 b) { return mul(div1(b), a); }
	intBil7 factorial(unsigned int a) {
		if (fact.empty()) fact.push_back(1);
		if (a >= bil7) return mul(factorial(bil7 - 1), a - bil7);
		for (int i = fact.size(); i <= a; i++) {
			fact.push_back(mul(fact.back(), i));
		}
		return fact[a];
	}
	intBil7 ifactorial(unsigned int a) { return div1(factorial(a)); }
	intBil7 C(unsigned int n, unsigned int m) {
		return mul(mul(factorial(n), ifactorial(n - m)), ifactorial(m));
	}
};
vector<intBil7> modBil7::fact;
vector<intBil7> modBil7::invfact;


int main(){
	intBil7 n, k; cin >> n >> k;
	modBil7 b7;

	for (int i = 1; i <= k; i++) {
		if (i > (n - k + 1)) {
			cout << 0 << endl;
			continue;
		}
		intBil7 r = b7.C(n - k + 1, i);
		intBil7 b = b7.C(k - 1, i - 1);
		cout << b7.mul(r, b) << endl;
	}

	return 0;
}


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

map<LL,int> cnt;
LL ans, sum; int n, a;

int main() {
	scanf("%d", &n);
	cnt[sum = 0]++;
	while (n--) {
		scanf("%d", &a);
		sum += a;
		ans += cnt[sum];
		cnt[sum]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12800
n = int(input())
a,z = [],[]
for _ in range(n):
	s = input()
	a.append(s.replace("?","a"))
	z.append(s.replace("?","z"))
t = input()
a.append(t)
z.append(t)
a,z = sorted(a)[::-1],sorted(z)
r,l = n+1-a.index(t),z.index(t)+1
for i in range(l,r): print(i,end=" ")
print(r)

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
const int N = 1e7 + 5; 
// int n;
int f[N];



int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){
int ans = 0;
int n;cin >>n;
// int f[n];
for(int i = 1; i<=n;i++){
	for(int j = 1; i *j<=n; j++){
		f[i*j]++;
	}
	ans += i*f[i];
}

cout << ans <<endl;








}
return 0;
}

// #include <bits/stdc++.h>
// #define vi               vector<int>
// #define pb(x)            push_back(x)
// #define all(x)           x.begin(), x.end()
// #define sortall(x)       sort(all(x))
// #define sortrev(x)       sort(all(x), greater<int>())
// #define debug(x)         cout << '>' << #x << ':' << x << endl;
// #define int              long long
// #define ld               long double
// #define endl 			 "\n";
// #define mp 				 make_pair
// #define pii 			 <int, int>
// #define lb 				 lower_bound
// #define ub				 upper_bound
// const int mod = 1000000007;
// using namespace std;
// const int N = 1e2 + 5; 
// // int n;
// vi dp(N, -1);

// // int a[N];
// int counts = 0;
// int fac(int n){
// 	for(int i = 1; i<=n; i++){
// 		if(n%i == 0){
// 			counts++;
// 		}
// 	}
// 	return counts;
// }

// int sol(vector <int> arr, int n){
// 	if(n == 1) dp[n] = 1;
// 	if(arr[n-1] != -1) arr[n-1];
// 	else arr[n-1] = n*fac(n);
// }

// int32_t main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// cout.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
// int t;
// t = 1;
// // cin >>t;
// while(t--){

// int n;cin >> n;

// int sum = 0;

// cout << sol(dp, n) <<endl;
// for(int i = 0 ; i <n; i++){
// 	if(dp[i] != -1){
// 		sum+=dp[i];
// 	}
// }

// cout << sum <<endl;
// for(auto x : dp)
// 	cout << x << " ";








// }
// return 0;
// }

Measured memory_bytes: 81744