akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000000000
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


struct UnionFind {
	vector<int> par;
  
  UnionFind(int N): par(N){
  	for(int i=0;i<N;i++) par[i] =i;
  }
};





int main(){
  ios::sync_with_stdio(false);
  
  string s,t;
  cin>>s>>t;
  
  int ss=s.size();
  int ts=t.size();
  
  int dp[ss+1][ts+1];
  rep(i,ss+1)rep(j,ts+1)dp[i][j]=0;
  
  
  for(int i= 1;i<ss+1;i++){
  	for(int j=1;j<ts+1;j++){
    	if(s[i-1]==t[j-1]){
        	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 = ss;
  int y = ts;
  while (dp[x][y]!=0){ 
  	if(dp[x][y] == dp[x-1][y]){
      --x;
    }else if(dp[x][y] == dp[x][y-1]){
      --y;
    }else{
     // cout<<x<<' '<<y<<endl;
    	ans +=s[x-1];
      	--x;
      	--y;
    } 
  }
  /*
  rep(i,ss+1){
  	rep(j,ts+1){
    	cout<<dp[i][j]<<' ';
    }
    cout<<endl;
  }
  */
  
  int vs=ans.size();
  for(int i = vs-1 ;i>=0;i--) cout<<ans[i];
  
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    lint n;
    cin >> n;
    string s;
    cin >> s;
    lint ans=0, c=0;
    vector<lint> p(3);
    REP(i, n) {
        if(s[i]=='R')
            p[0]++;
        if (s[i] == 'G')
            p[1]++;
        if (s[i] == 'B')
            p[2]++;
    }

    REP(i, n){
        REP(j,n){
            if(i+2*j>n-1){
                break;
            }
            if (s[i] != s[i + j] && s[i] != s[i + 2*j] && s[i+j] != s[i + 2*j]){
                c++;
            }
        }
    }
    ans = p[0] * p[1] * p[2]-c;

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct items{
    ll t, v;
};
static const ll MAX = 100001;

bool asc( const items& left, const items& right ) {
    return left.v == right.v ? left.t < right.t : left.v < right.v;
}
int main() {
    

    ll n,k;
    cin >> n >> k;
    vector <items> lis, rem;
    for (ll i=0;i<n;i++){
        items p;
        cin >> p.t >> p.v;
        lis.push_back(p);
    }
    sort(lis.begin(), lis.end(), asc);
    reverse(lis.begin(), lis.end());
    ll eachmax[MAX] = {};
    ll per = 0;
    for(ll i=0;i<n;i++){
        if(eachmax[lis[i].t] < lis[i].v){
            eachmax[lis[i].t] = lis[i].v;
        }
    } 
    ll numt = 0;
    ll exist[MAX] = {};
    for(ll i=0;i<k;i++){
        per += lis[i].v;
        if(exist[lis[i].t] == 0){
            numt++;
        }else{
            rem.push_back(lis[i]);
        }
        exist[lis[i].t] = 1;
//        cout << lis[i].t << endl;
    }
    reverse(rem.begin(), rem.end());
    ll ans = 0;
    if(ans < per + numt*numt){
        ans = per + numt*numt;
    }

//    cout << ans << endl;
    vector <ll> memo;
    for (ll i=0;i<n;i++){
        if(exist[i] == 0 and eachmax[i] > 0){
            memo.push_back(eachmax[i]);
        }
    }
    sort(memo.begin(), memo.end());
    reverse(memo.begin(), memo.end());
//    cout << rem.size() << endl;
//    cout << memo.size() << endl;
    for(ll i = 0;i<min(memo.size(), rem.size());i++){
        per -= rem[i].v;
        per += memo[i];
        numt++;
        if(ans < per + numt*numt){
            ans = per + numt*numt;
        }
//        cout << ans << endl;
    }
//    cout << "mofu" << endl;
    cout << ans << endl;


}




Measured memory_bytes: 5104
import sys
n, k = map(int, input().split())
s = input()
sList = [] #連続する1の数、0の数、1の数...と格納するリスト
switch = int(s[0])
num = 1
if int(s[0]) == 0:
  sList.append(0)
if n > 1:
  for i in range(1, n):
    if int(s[i]) == switch:
      num += 1
    else:
      sList.append(num)
      num = 1
      switch = int(s[i])
sList.append(num)
if len(sList) // 2 < k: #全部ひっくり返せる
  print(n)
  sys.exit()
elif len(sList) % 2 == 0: #最後が0の数で終わっている場合、1の数で終わらせる
  sList.append(0)
  
s = sum(sList[0:2*k+1])
sMax = s

for i in range(1, (len(sList)-2*k) // 2 + 1): #リストの2k+1個の部分和のうち、最大のものが答え
  s += - sList[2*i-2] - sList[2*i-1] + sList[2*i+2*k] + sList[2*i+2*k-1]
  if sMax < s:
    sMax = s
    
print(sMax)

Measured memory_bytes: 4596
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
t=s0()

ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
print(ans)

Measured memory_bytes: 9556
#include <iostream>
#include <string>
struct data{
  std::string s;
  int p,n;
};
void sortBubble(data *a,size_t n){
  int i,j;
  for (i=0;i<n;i++){
    for (j=n-1;j>i;j--){
      if (a[j].s<a[j-1].s){
        std::swap(a[j],a[j-1]);
      }
    }
  }
}
void sortBubble2(data *a,size_t n){
  int i,j;
  for (i=0;i<n;i++){
    for (j=n-1;j>i;j--){
      if (a[j].p>a[j-1].p){
        std::swap(a[j],a[j-1]);
      }
    }
  }
}

int main(){
  int n,i;
  std::cin >> n;
  struct data a[n];
  for (i = 0; i <n; i++)std::cin >> a[i].s>>a[i].p;
  for (i = 0; i <n; i++)a[i].n=i+1;
  sortBubble2(a,n);
  sortBubble(a,n);
  for (i = 0; i <n; i++)std::cout << a[i].n << '\n';

}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector <int>d(N);
    for(int i=0 ; i<N ; i++){
        cin>>d[i];
    }
	int ans=1;
	sort(d.begin(),d.end());
	for(int i=N-1 ; i>0 ; i--){
		if(d[i]!=d[i-1])ans+=1;
	}
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,a;
  cin >> n >> a;
  cout << (n*n-a) << endl; 


return 0;
}
///....


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		boolean[] isClear = new boolean[N];
		for (int i = 0; i < N; i++)
			isClear[i] = false;

		int[] cntWrong = new int[N];
		for (int i = 0; i < N; i++)
			cntWrong[i] = 0;
		
		int cntCorrect = 0;
		sc.nextLine();
		for (int j = 0; j < M; j++) {
			int num = sc.nextInt() - 1;
			String result = sc.nextLine();
			if (!isClear[num]) {
				if (result.equals(" AC")) {
					isClear[num] = true;
					cntCorrect++;
				} else {
					cntWrong[num]++;
				}
			}
		}
		
		int sumCorrect = 0;
		for (int i = 0; i < N; i++) {
			if (isClear[i])
				sumCorrect += cntWrong[i];
		}

		System.out.println(cntCorrect + " " + sumCorrect);

		sc.close();

	}

}

Measured memory_bytes: 149764
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int num[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	sort(num,num+n);
	int ans=0;
	int k=0;
	while(k<n)
	{
		int count=0;
		int last=num[k];
		while(k<n&&num[k]==last)
		{
			count++;
			k++;
		}
		ans+=count%2;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main(void){
    int A,B,C,temp;
    std:: cin >> A >> B >> C;
    temp = A;
    A = B;
    B = temp;
    temp = A;
    A = C;
    C = temp;
    std:: cout << A << " "<< B << " "<< C;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 101
 
int main(void){
  int Adj[MAX][MAX];
  int i, j, n, u, k, v;
 
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      Adj[i][j] = 0;
    }
  }
 
  for(i=1; i<n+1; i++){
    scanf("%d%d", &u, &k);
    for(j=1; j<k+1; j++){
      scanf("%d", &v);
      Adj[i][v] = 1;
    }
  }
 
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      if(j == n) printf("%d\n", Adj[i][j]);
      else printf("%d ", Adj[i][j]);
    }
  }
 
  return 0;
}

Measured memory_bytes: 636
n = int(input())
B = [[0 for i in range(n)] for j in range(n)]
chk = [0 for i in range(n)]
s = []
i_array = [0 for i in range(n)]
time = 1
node_start_time = [0 for i in range(n)]
node_finish_time = [0 for i in range(n)]

for i in range(n):
    A = list(map(int,input().split()))
    for j in range(A[1]):
        B[A[0]-1][A[j+2]-1] = 1

for i in range(n):
    if(chk[i] == 1):
        continue
    chk[i] = 1
    node_start_time[i] = time
    time += 1
    s.append(i)
    while(len(s) != 0):
        flag = 0
        v = s[len(s)-1]
        for j in range(i_array[v],n):
            if(B[v][j] == 1 and chk[j] == 0):
                chk[j] = 1
                s.append(j)
                node_start_time[j] = time
                time += 1
                i_array[v] = j+1
                flag = 1
                break
        if(flag == 0):
            s.pop()
            node_finish_time[v] = time
            time += 1

for i in range(n):
    print(i+1,node_start_time[i],node_finish_time[i])


Measured memory_bytes: 5744
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int n=getInt();

		long[]a=REPS(n).mapToLong(i->s.nextLong()).toArray(),dec=new long[n];

		long decsumlast=0,r=0,max=Long.MAX_VALUE;

		while(max+decsumlast>=n){
			max=0;
			long decsum=0;
			for(int i=0;i<n;++i) {
				a[i]+=decsumlast-dec[i];
				r+=a[i]/n;
				decsum+=a[i]/n;
				dec[i]=a[i]/n;
				a[i]%=n;

				max=Math.max(max,a[i]);
			}
			decsumlast=decsum;
//			System.out.println(max);
//			System.out.println(Arrays.toString(a));
		}

		System.out.println(r);
	}
}


Measured memory_bytes: 28884
import 'dart:io';
 
void main(List<String> args) {
  int K = int.parse(stdin.readLineSync());
  List<int> A = stdin.readLineSync().split(' ').map((i) => int.parse(i)).toList();
  String ans = "NG";
  for(int i=A[0]; i<=A[1]; ++i){
  	if(i%K==0) ans = "OK";
  }
  print(ans);
}

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

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;

    int tp = 0, xp = 0, yp = 0;
    for (int i = 0; i < n; ++i) {
        int t, x, y;
        cin >> t >> x >> y;
        if (abs(x - xp) + abs(y - yp) > t - tp || (abs(x - xp) + abs(y - yp)) % 2 != (t - tp) % 2) {
            cout << "No" << endl;
            return;
        }
        tp = t;
        xp = x;
        yp = y;
    }
    cout << "Yes\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
#define db(a) cout << a<< endl;
typedef pair <int,int>P;
int main(){
    int a,b;
    cin >>a>>b;
    if (a+b>=10) cout << "error"<<endl;
    else cout << a+b <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// 木になるようにグラフを構築する必要がある
// 同時に二つの未確定の頂点の配色を確定させるか、すでに確定した頂点から未確定の頂点を確定させるようにすれば、木にできる
// (確定させている頂点同士に辺が張られることはないから)
// Diが小さい値のやつから決める

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> D(N);
    map<int, vector<int>> ma;
    repeat(i, N) {
        cin >> D[i];
        ma[D[i]].push_back(i);
    }
    auto G = vectors(make_pair(0, 0), N, 0);
    repeat(i, M) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].emplace_back(v, i);
        G[v].emplace_back(u, i);
    }

    vector<int> color(N, -1);
    vector<int> res(M, 1000000000);
    for (auto &it : ma) {
        int d = it.first;
        auto &v_vec = it.second;
        for (int v : v_vec) {
            if (color[v] != -1) continue;
            bool flg = false;
            for (auto e : G[v]) {
                int nv = e.first;
                if (D[v] < D[nv]) continue;
                res[e.second] = d;
                if (color[nv] == -1) {
                    color[v] = 0;
                    color[nv] = 1;
                } else {
                    color[v] = 1 - color[nv];
                }
                flg = true;
                break;
            }
            if (!flg) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    repeat(i, N) {
        if (color[i])
            cout << "W";
        else
            cout << "B";
    }
    cout << endl;
    repeat(i, M) {
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 22732
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,q;
  cin>>n>>q;
  
  ll c,x,y;
  fenwick_tree<ll> fw(n);
  
  rep(i,n){
    cin>>x;
    fw.add(i,x);
  }
  
  rep(i,q){
    cin>>c>>x>>y;
    if(c==0) fw.add(x,y);
    else cout<<fw.sum(x,y)<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 8220
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s];i;i=e[i].nxt)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
typedef double db;
const db pi=acos(-1.0);
int main()
{
	db r; sd(r);
	printf("%.12lf\n",2*pi*r);
	return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}






ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};

struct UnionFind {
    vector<int>d;
    UnionFind(int n=0):d(n,-1){}
    int find(int x){
        if((d[x])<0)return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x,int y){
        x =find(x);y=find(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return find(x)==find(y);};
    int size(int x){return -d[find(x)];};
};

int deg[100005];
vector<int> to[100005];


ll n,m,q;
vector<ll>a,b,c,d;
ll ans;

void dfs(vector<ll> A){
    if(A.size()==n+1){
        ll sum=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i])sum+=d[i];
        }
        ans=max(ans,sum);
        return;
    }
    
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n) {
    if(n==0)return 1;
    mint x=f(2/n);
    x*=x;
    if(n%2==1)x*=2;
    return x;
}

mint choose(int n,int a){
    mint x =1,y=1;
    rep(i,a){
      x*=n-i;
      y*=a+i;
    }
    return x/y;
}

int main()
{
  ll n;
  cin>>n;
  ll sum=0;
  Rep(i,n+1){
      ll e=n/i;
      sum+=(i+e*i)*e/2;
  }
  cout<<sum<<endl;
}
 




Measured memory_bytes: 5924
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000050
mt19937 myrand(time(0));

ll f(ll x, ll m){
    return (x*x)%m;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n,x,m,sum=0;
    cin>>n>>x>>m;
    ll now=f(x,m),idx=0;
    vector<int> v,vis(m,0);
    while(!vis[now]){
        v.pb(now);
        vis[now]=++idx;
        now=f(now,m);
    }
    n--;
    ll sz=(int)v.size()-vis[now]+1;
    ll ans=x;
    for(int i=0;i<(vis[now]-1);i++){
        if(n==0) break;
        ans+=v[i];
        n--;
    }
    ll cnt=n/sz;
    for(int i=vis[now]-1;i<(int)v.size();i++) sum+=v[i];
    ans+=(cnt*sum);
    ll rem=n%sz;
    for(int i=vis[now]-1;i<(int)v.size();i++){
        if(rem==0) break;
        rem--;
        ans+=v[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> l(n),a(n);
    a[0] = 0;
    for(int i = 0;i < n;i ++){
        cin >> l[i];
        a[0] += l[i]*(ll)pow(-1,i);
    }
    cout << a[0] << " ";
    for(int i = 1;i < n;i ++){
        a[i] = 2*l[i-1]-a[i-1];
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int Y = sc.nextInt();
		
		for(int x = 0; x <= N; x++){
			if(10000 * x > Y) continue;
			for(int y = 0; y <= N - x; y++){
				int z = N - x - y;
				int xx = 10000 * x;
				int yy = 5000 * y;
				int zz = 1000 * z;
				if(xx + yy + zz == Y){
					System.out.println(x + " " + y + " " + z);
					//System.out.println(xx + " " + yy + " " + zz);
					return;
				}
			}
		}
		
		System.out.println("-1 -1 -1");
	}
}

Measured memory_bytes: 25172
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var k = int.Parse(Console.ReadLine());
        List<long> runrun = new List<long>();
        List<long> lastDig = Enumerable.Range(1, 9).Select(x => (long)x).ToList();
        runrun.AddRange(lastDig);
        while (true)
        {
            List <long> newLastDig = new List<long>();
            foreach (var item in lastDig)
            {
                var i = item % 10;
                if (i != 0) newLastDig.Add(item * 10 + i - 1);
                newLastDig.Add(item * 10 + i);
                if (i != 9) newLastDig.Add(item * 10 + i + 1);
            }
            runrun.AddRange(newLastDig);
            lastDig = newLastDig;
            if (runrun.Count > k) break;
        }
        Console.WriteLine(runrun.OrderBy(x => x).Take(k).Last());
    }
}

Measured memory_bytes: 22752
import math
a ,b ,x = map(int,input().split())
if x <= a*a*b/2:
  c = 2*x/(a*b)
  tan = b/c
  rad = math.atan(tan)
  deg = math.degrees(rad)
else:
  c = a*a*b - x
  d = 2*c/(a*a)
  tan = d/a
  rad = math.atan(tan)
  deg = math.degrees(rad)
print(deg)

Measured memory_bytes: 3060
#include <stdio.h>

#define index_max 250

int main(){
  int i;
  int n,a[index_max];
  int left_search,right_search;

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

  for(i = 0 ; i < n ; i++){
    printf("node %d: key = %d, " ,i+1 ,a[i]);

    if(i){
      printf("parent key = %d, " ,a[(i+1)/2-1]);
    }
    left_search=2*i+1;
    if(left_search < n){
      printf("left key = %d, " ,a[2*i+1]);
    }
    right_search=2*i+2;
    if(right_search < n){
      printf("right key = %d, " ,a[2*i+2]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int l = s.length();
    int count = 0;
    int ans = 0;
    for(int i = 0; i < l; i++){
        if(s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C'){
            count++;
            ans = max(ans, count);
            }
        else count = 0;
        //cout << count << endl;
    }
    cout << ans << endl;
}

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

// SW配列とox配列に矛盾があればfalse, 無ければtrue
bool check(string s, string t) {
  int n = s.size();
  for (int i = 0; i < n; i++) {
    int l = i - 1;
    if (l < 0) l = n - 1;
    int r = i + 1;
    if (r >= n) r = 0;
    if (s.at(i) == 'S' && t.at(i) == 'o') if (s.at(l) != s.at(r)) return false;
    if (s.at(i) == 'S' && t.at(i) == 'x') if (s.at(l) == s.at(r)) return false;
    if (s.at(i) == 'W' && t.at(i) == 'o') if (s.at(l) == s.at(r)) return false;
    if (s.at(i) == 'W' && t.at(i) == 'x') if (s.at(l) != s.at(r)) return false;
  }
  return true;
}

// 決め打ちされた1番2番を元にSW配列を生成
string make(string s, string t) {
  int n = t.size();
  for (int i = 1; i < n - 1; i++) {
    char pre = s.at(i - 1);
    if (s.at(i) == 'S' && t.at(i) == 'o') s += pre;
    if (s.at(i) == 'S' && t.at(i) == 'x') s += char('S' ^ 'W' ^ pre);
    if (s.at(i) == 'W' && t.at(i) == 'o') s += char('S' ^ 'W' ^ pre);
    if (s.at(i) == 'W' && t.at(i) == 'x') s += pre;
  }
  return s;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  for (auto s : {"SS", "SW", "WS", "WW"}) { // 1番2番を決め打ち
    string ans = make(s, S);
    if (check(ans, S)) return cout << ans << "\n", 0;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 3936
import           Control.Monad.ST            (ST)
import           Data.Bits                   (shiftR)
import qualified Data.ByteString.Char8       as B
import           Data.Char                   (isSpace)
import           Data.Maybe                  (fromJust)
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  [n, k] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
  hs <- V.unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine :: IO (V.Vector Int)
  print $ solve n k hs

solve :: Int -> Int -> V.Vector Int -> Int
solve n k hs = V.sum . kill n k $ sort' hs where

kill :: Int -> Int -> V.Vector Int -> V.Vector Int
kill n k = V.take (n - k)

sort' :: (V.Unbox a, Ord a) => V.Vector a -> V.Vector a
sort' = V.modify (\v -> quicksort v 0 (VM.length v))

-- https://github.com/as-capabl/haskell-qsort-pfm/blob/master/src/UV.hs
quicksort :: (V.Unbox a, Ord a) => VM.STVector s a -> Int -> Int -> ST s ()
quicksort work iStart iEnd
    | iEnd - iStart <= 1 = return ()
    | otherwise = do
        pivot <- VM.unsafeRead work (((iEnd - iStart) `shiftR` 1) + iStart)
        med <- divide pivot iStart (iEnd - 1)
        quicksort work iStart med
        quicksort work med iEnd
  where
    divide pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise = do
            lower <- shrinkLower pivot iS' iE'
            higher <- shrinkHigher pivot lower iE'
            if lower >= higher
              then do
                return lower
              else do
                swapWork lower higher
                divide pivot (lower + 1) (higher - 1)

    shrinkLower pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise = do
            x <- VM.unsafeRead work iS'
            if x >= pivot
              then
                return iS'
              else
                shrinkLower pivot (iS' + 1) iE'

    shrinkHigher pivot iS' iE'
        | iS' > iE' = return iE'
        | otherwise = do
            x <- VM.unsafeRead work iE'
            if x <= pivot
              then
                return iE'
              else
                shrinkHigher pivot iS' (iE' - 1)

    swapWork i j = VM.unsafeSwap work i j



Measured memory_bytes: 11900
// ABC_086_B

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

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

	string st = s + t;

	int n = stoi(st);

	int sq = sqrt(n);

	if(sq * sq == n) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}
	        

Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


char S_in[1002];

int main(int argc, char* argv[]){
    int i,j,k;
    int S_l;
    int temp=0;
    scanf("%s",S_in);
    printf("%s",S_in);    
    if(S_in[strlen(S_in)-1]=='s'){
        printf("es");
    }else{
        printf("s");
    }
    return 0;
}

Measured memory_bytes: 1688
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st, st2;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    private static boolean canDo(int i, int[] A, int M, int V, int P) {
        if (A.length - i <= P) {
            return true;
        }

        V -= Math.min(V, P);
        long max = A[i] + M;
        long left = (long)V * M;


        for (int j = 0; j < A.length - (P-1); j++) {
            if (i == j) continue;
            if (A[j] > max) return false;
            left -= Math.min(M, max - A[j]);
        }
        return left <= 0;
    }

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        int V = Integer.parseInt(st.nextToken());
        int P = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(st.nextToken());
        }
        Arrays.sort(A);
        // System.out.println(canDo(3, A, M, V, P));

        int a = 0;
        int b = N-1;
        while (a != b) {
            int mid = (a + b) / 2;
            // System.out.println(mid);
            if (canDo(mid, A, M, V, P)) {
                b = mid;
            } else {
                a = mid + 1;
            }
        }
        // System.out.println(a);
            // i
        pw.println(N - a);

        pw.close();
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int a, b;

    Pair(int _a, int _b){
        a = _a;
        b = _b;
    }
 
    public String toString(){
        return a + " " + b;
    }

    public int compareTo(Pair p){
        if (b != p.b) return b < p.b ? -1 : 1;
        if (a != p.a) return a < p.a ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 37880
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};

void solve() {
  for (;;) {
    vs s(12);
    rep(i, 12) if (!(cin >> s[i])) return;
    int c = 0;
    rep(i, 12) rep(j, 12) {
      function<void(int, int)> dfs = [&](int i, int j) {
        if (i < 0 || j < 0 || i >= 12 || j >= 12 || s[i][j] == '0') return;
        s[i][j] = '0';
        rep(k, 4) dfs(i + di[k], j + dj[k]);
      };
      c += s[i][j] == '1';
      dfs(i, j);
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x  = new Scanner(System.in);
		int n = x.nextInt();
		int[] price = new int[n];
		for(int m = 0 ; m < n ; m++){
			price[m] = x.nextInt();
		}
		System.out.print(price[n-1]);
		for(int g = n-2 ; g >= 0 ; g--){
			System.out.print(" " + price[g]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 17204
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <limits>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a * c <= b)
    cout << c << endl;
  else
    cout << b / a << endl;

  return 0;
}


Measured memory_bytes: 256
N, M, X = $stdin.gets.split.map {|i| i.to_i }
C = []
A = []
0.upto(N - 1) do |i|
  C[i], *A[i] = $stdin.gets.split.map {|j| j.to_i }
end
cost_min = -1
1.upto((1 << N) - 1) do |bits|
  cost = 0
  us = [0] * M
  0.upto(N - 1) do |i|
    if bits[i] != 0
      cost += C[i]
      A[i].each_with_index do |aij, j|
        us[j] += aij
      end
    end
  end
  #$stderr.printf "%0*b / cost = %d, us = %s\n", N, bits, cost, us
  ok = true
  us.each do |u|
    if u < X
      ok = false
      break
    end
  end
  if ok && (cost_min == -1 || cost_min > cost)
    cost_min = cost
  end
end
puts cost_min


Measured memory_bytes: 14420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;


int main() {
	int m, d; cin >> m >> d;
	int count = 0;
	for (int _m = 4; _m <= m; _m++) {
		for (int _d = 1; _d <= d; _d++) {
			int d1 = _d % 10;
			int d10 = _d / 10;
			if (d1 >= 2 && d10 >= 2 && d1 * d10 == _m) count++;


		}
		
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
    int main(void){
        int H,W,h,w;
        const char s = '#';
        const char p = '.';

        cin >> H >> W;
        while(W!=0 && H!=0){
            for ( h = 1; h <= H; h++) {
                for ( w = 1; w <= W; w++ ){
                    if( ( w + h ) % 2 == 0 ){
                        cout << s;
                    }
                    else{
                        cout << p;
                    }
                }
            cout << endl;
            }
        cout << endl;
        cin >> H >> W;
        }
    }


Measured memory_bytes: 3076
s = input()

ml = []

for i in list(range(1, 13)):
    i = str(i)
    if len(i) == 1:
        ml.append("0"+i)
    else:
        ml.append(i)
        
if s[:2] not in ml and s[-2:] not in ml:
    print('NA')
    
elif s[:2] in ml and s[-2:] in ml:
    print("AMBIGUOUS")
    
elif s[:2] in ml:
    print("MMYY")

else:
    print("YYMM")

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
typedef long long ll;
const int N=2e5+9;
struct sa
{
    int x;
    int y;
};
ll a[3006];
int main()
{
    int d,r;
    while(scanf("%d %d",&r,&d)!=-1)
    {
        scanf("%lld",&a[0]);
        for(int i=1;i<=10;i++)
        {
            a[i]=r*a[i-1]-d;
            printf("%lld\n",a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
  string s; cin >> s;
  int n = s.size();
  vector<ll> dp1(n + 1, 0), dp2(n + 1, 0);
  dp2[0] = 1;
  for(int i = 0; i < n; i++){
    (dp1[i + 1] += 3 * dp1[i]) %= MOD;
    if(s[i] == '1'){
      (dp1[i + 1] += dp2[i]) %= MOD;
      (dp2[i + 1] += 2 * dp2[i]) %= MOD;
    }
    else{
      (dp2[i + 1] += dp2[i]) %= MOD;
    }
  }
  ll ans = (dp1[n] + dp2[n]) % MOD;
  printf("%lld\n", ans);
}

Measured memory_bytes: 5100
// D - Triangles
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()

int solve(int N, vi &L){
	sort(all(L));
	int ans = 0;
	rp(ia, 0, N-2){
		int minL = L[ia];
		rp(ib, ia+1, N-1){
			int midL = L[ib];
			rp(ic, ib+1, N){
				int maxL = L[ic];
				if(maxL < minL + midL ){
					ans++;
				}
			}
		}
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi L(N);
	rp(i, 0, N) cin>>L[i];
	cout<< solve(N, L) <<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,T;cin>>N>>T;
  int minc=INF;
  repeat(i,N){
    int c,t;cin>>c>>t;
    if(t<=T){
      minc=min(minc,c);
    }
  }
  if(minc==INF){
    cout <<"TLE"<<endl;
  }else{
    cout << minc << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a),end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << " = " << a << ENDL;
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;


int main()
{   _
    lli MX;
    cin >> MX;
    vector<lli> divs(MX + 5, 1);
    lli ans = 1;
    for(lli i = 2; i <= MX; ++i) {
        for(lli j = i; j <= MX; j += i) ++divs[j];
        ans += divs[i] * i;
    }
    cout << ans << ENDL;
    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll R;
    cin >> R;
    double ans = 2 * (double)R * M_PI;

    cout << fixed;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3780
fun main() {
    val builder = StringBuilder()

    val (n, k) = readInputLine().split(" ").map { it.toInt() }
    var aArr = readInputLine().split(" ").map { it.toInt() }.toIntArray()

    for (i in 1..k.coerceAtMost(50)) {
        val bArr = IntArray(n)

        for (j in 0 until n) {
            val l = (j - aArr[j]).coerceAtLeast(0)
            val r = (j + aArr[j]).coerceAtMost(n - 1)
            bArr[l]++
            if (r + 1 < n) {
                bArr[r + 1]--
            }
        }

        for (j in 1 until n) {
            bArr[j] += bArr[j - 1]
        }

        aArr = bArr
    }


    builder.appendln(aArr.joinToString(" "))

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 72312
#include <iostream>
using namespace std;
 
int main(){
    int n;
    int min=1000000, max=-1000000;
    long sum=0;
    cin >> n;
    for(int i=0; i<n; i++){
        int in;
        cin >> in;
        if(in<min) min = in;
        if(in>max) max = in;
        sum += in;
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
int32_t main()
{
     int n;
     cin>>n;
     int answer=0;
     int a=0,b=0,c=0;
     vector<string> v1,v2;
     for(int j=0;j<n;j++)
     {
		 string str;
		 cin>>str;
		 int l=str.size();
		 int i;
		 for(i=0;i<l-1;i++)
		 {
			 if(str[i]=='A'&&str[i+1]=='B')
			    answer++;
		 }
		 if(str[l-1]=='A'&&str[0]!='B')
		 {
			a++;
		 }
		 if(str[0]=='B'&&str[l-1]!='A')
		 {
			 b++;
		 }
		 if(str[0]=='B'&&str[l-1]=='A')
		 {
			 c++;
		 }
	 }
     if(c==0)
     {
		 answer+=min(a,b);
	 }
	 else
	 {
		 if(a+b>0)
		 {
			 answer+=min(a,b)+c;
		 }
		 else
		 {
			 answer+=c-1;
		 }
	 }
	 cout<<answer<<endl;
}


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

int main() {  
	int n,q;
  	cin >>n;
  	int S[n];
  	for(int i=0;i<n;i++){
    cin >>S[i];
    }
  	cin >>q;
  	int t,left,right,mid,count=0;
  	for(int i=0;i<q;i++){
		cin >>t; 
      	left=0;right=n;
      	while(left<right){
        	mid=(left+right)/2;
          	if(t==S[mid]){count++;break;}
            if(t>S[mid]){left = mid+1;}
          	else if(t<S[mid]){right = mid;}
        }
    } 	
  cout <<count <<endl;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[3005][3005], A[3000];
int main() {
    init();
    ll N,S;
    cin >> N >> S;
    rep(i, N) cin >> A[i];

    dp[0][0] = 1;
    rep(i,N){
        rep(j,S+1){
            dp[i + 1][j] = dp[i][j] * 2 % MOD;
            if(j>=A[i])
                (dp[i + 1][j] += dp[i][j - A[i]]) %= MOD;
        }
    }

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

Measured memory_bytes: 74048
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n;
    cin>>n;
    vector<long long> arr(n);
    map<long long, int> feqcnt;
    for(int i = 0; i < n; i++) {
        cin>>arr[i];
        feqcnt[arr[i] + i + 1]++;
    }
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        long long seq = (i + 1) - arr[i];
        ans += feqcnt[seq];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27488
def myAnswer(N:int,A:list) -> int:
   dic ={}
   for i in range(1,N+1):
      dic[i]=A[i - 1]
   ans = sorted(dic.items(), key=lambda x:x[1])
   for a in ans:
      print(a[0],end=" ")
   print()
def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))

   myAnswer(N,A[:])

if __name__ == '__main__':
   main()

Measured memory_bytes: 26404
n,k,q=list(map(int,input().split()))
list_=[k-q for i in range(n)]

list_winner=[]

for i in range(q):
    list_winner.append(int(input()))

for i in range(q):
    list_[list_winner[i]-1]+=1

for i in range(n):
    if list_[i]>0:
        print("Yes")
    else:
        print("No")

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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define PI 3.14159265358979323846264338327950L
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
int t;

void slove()
{
	string s;cin >> s;
	int n = s.size();
	n = n - 2;
	while(n)
	{
		string l = s.substr(0 , n / 2);
		string r = s.substr(n / 2 , n - n / 2);
		if(l == r)
		{
			cout << n << endl;
			return;
		}
		n -= 2;
	}
}
int main()
{
	SIS;
	slove();
}

Measured memory_bytes: 3620
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

l = 1

for i in T:
    l = lcm(l, i)

print(l)

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# すぬけ君リスト
l = [0] * N
# お菓子
i = 1
for i in range(1, K+1):
   di = int(input())
   Aidi = input().split()
   for sunuke_num in Aidi:
       l[int(sunuke_num) - 1] += i
# 出力
trick_num = 0
for sunuke_okasi in l:
    if sunuke_okasi == 0:
        trick_num += 1

print(trick_num)

Measured memory_bytes: 9132