akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=200005;

int n;
int data[maxn];

int main() {
    while(cin>>n){
        LL x=0, y=0;
        for(int i=0;i<n;i++){
            cin>>data[i];
            y+=data[i];
        }
        LL ans=inf;
        for(int i=0;i<n-1;i++){
            y-=data[i];
            x+=data[i];
            ans=min(ans, abs(x-y));
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
int n;
ll a[N], k;
ll ans;
int nd = 0, cnt[100];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%lld", &a[i]);
	for (int i = 3; i <= n; i++)k ^= a[i];
	ll s = a[1] + a[2];
	for (int i = 50; i >= 0; i--) {
		int x = (s >> i & 1), y = (k >> i & 1);
		if (x == 0 && y == 0) {
			if (nd)cnt[i] = 2, ans |= (1ll << i);
			else cnt[i] = 0;
			nd = 0;
		}
		else if (x == 1 && y == 1) {
			if (nd) { puts("-1"); return 0; }
			else cnt[i] = 1;
			nd = 0;
		}
		else if (x == 1 && y == 0) {
			if (nd)cnt[i] = 2, ans |= (1ll << i);
			else cnt[i] = 0;
			nd = 1;
		}
		else {
			if (nd)cnt[i] = 1;
			else { puts("-1"); return 0; }
			nd = 1;
		}
	}
	if (nd == 1) { puts("-1"); return 0; }
	for (int i = 50; i >= 0; i--) {
		if (cnt[i] == 1 && ans + (1ll << i) <= a[1]) {
			ans += (1ll << i);
		}
	}
	if (ans > a[1] || ans == 0)puts("-1");
	else printf("%lld\n", a[1] - ans);
	return 0;
}

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

int main (){
    int a,b,N;
    char S[100];
    int c=0;

    scanf("%d",&N);

    scanf("%s",S);
    for(b=0;b+1<N;b++){
        if(S[b]=='A' && S[b+1] == 'B' && S[b+2] == 'C'){
c++;
        }else{}
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string[] args;

		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int M = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);
		
		int[] B = new int[M];
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < M; i++)
			B[i] = Int32.Parse(args[i]);
		
		int[,] A = new int[N,M];
		for(int i = 0; i < N; i++)
		{
			args = Console.ReadLine().Split(' ');
			for(int j = 0; j < M; j++)
				A[i,j] = Int32.Parse(args[j]);			
		}
		
		int ans = 0;
		for(int i = 0; i < N; i++)
		{
			int sum = 0;
			for(int j = 0; j < M; j++)
				sum += A[i,j] * B[j];
			sum += C;
			if(sum > 0)
				ans++;
		}
		
		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct vertex{
    vector<int> E;//cost,to
};
#define MAX_V 100
#define MAX_E 1000

bool isVisited[MAX_V];
bool isChecked[MAX_V];
vertex V[MAX_V];

bool rec(int i){
    isVisited[i]=true;
    isChecked[i]=true;
    for(auto&e:V[i].E){
        if(isVisited[e]){
            return true;
        }else if(!isChecked[e]){
            if(rec(e)){
                return true;
            }
        }
    }
    isVisited[i]=false;
    return false;
}

int main(){
    int nv,ne;
    cin>>nv>>ne;
    
    for(int i=0;i<ne;i++){
        int s,t;
        cin>>s>>t;
        V[s].E.emplace_back(t);
    }
    
    fill(isVisited,isVisited+MAX_V,false);
    fill(isChecked,isChecked+MAX_V,false);
    for(int i=0;i<nv;i++){
        if(isChecked[i])continue;
        if(rec(i)){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3156
N = input()
if int(N[-1]) == 2:
    print('hon')
elif int(N[-1]) == 4:
    print('hon')
elif int(N[-1]) == 5:
    print('hon')
elif int(N[-1]) == 7:
    print('hon')
elif int(N[-1]) == 9:
    print('hon')
elif int(N[-1]) == 0:
    print('pon')
elif int(N[-1]) == 1:
    print('pon')
elif int(N[-1]) == 6:
    print('pon')
elif int(N[-1]) == 8:
    print('pon')
else:
    print('bon')

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

const int INF = 1<<30;
int N, Q;
string S;

void solve() {
    vector<BIT<int>> pls(26, BIT<int>(N+10));
    for (int i = 0; i < N; ++i) pls[S[i]-'a'].add(i+1, 1);
    while (Q--) {
        int type; cin >> type;
        if (type == 1) {
            int ind; char nc; cin >> ind >> nc; --ind;
            auto pc = S[ind];
            S[ind] = nc;
            pls[pc - 'a'].add(ind+1, -1);
            pls[nc - 'a'].add(ind+1, 1);
        }
        else {
            int l, r; cin >> l >> r; --l;
            int res = 0;
            for (int c = 0; c < 26; ++c) if (pls[c].sum(l+1, r+1)) ++res;
            cout << res << endl;
        }
    }
}

int main() {
    cin >> N >> S >> Q;
    solve();
}


Measured memory_bytes: 53636
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int cnt,L[MAX/2+2],R[MAX/2+2];

void merge(int A[],int n,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i = 0,j = 0,k;
  
  for (i = 0;i<n1;i++) L[i]=A[left+i];
  for (i = 0 ; i<n2;i++) R[i] = A[mid + i];

  L[n1] = R[n2] = SENTINEL;

  i = 0;
  j = 0;
  for (k = left ; k< right ;k++){
    cnt++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
	j++;
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  if (left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A,n,left, mid);
    mergeSort(A,n, mid, right);
    merge(A,n, left, mid, right);
  }
}
int main(){
  int A[MAX],n,i;
  cnt=0;

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

  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}




Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string t = "2019/04/30";
  if(s<=t){
    cout<<"Heisei"<<endl;
  }
  else{
    cout<<"TBD"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int N;
    cin >> N;
    int o = 0, f = 0, temp;
    for(int i = 0; i < N; i++){
        cin >> temp;
        if(temp%4 == 0) f++;
        else if(temp%2 != 0) o++;
    }

    if(f >= o or (f==o-1 and f+o==N)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll max;
    cin >> max;
    ll ans = 0;
    rep(i,n-1){
        ll a;
        cin >> a;
        if(max > a) ans += max - a;
        else max = a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#pragma GCC optimize(2) //O2优化？

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
using namespace std;

char c[55][55];

int main(){
	int n,m;
	cin>>n>>m;
	rep(i,n) scanf("%s",c[i]);
	rep(i,n){
		rep(j,m){
			if(c[i][j]=='#'){
				if((c[i][j+1]=='#') ||
				   (c[i][j-1]=='#') ||
				   (c[i+1][j]=='#') ||
				   (c[i-1][j]=='#'))
				   	continue;
				else END("No")
			}
		}
	}
	END("Yes")
	return 0;
}

Measured memory_bytes: 256
N = int(input())
rawA = list(map(int, input().split()))
A = [rawA[0],] + rawA + [rawA[N-1],]
#要素数A+2。A[0]とA[N+1]はcumsum計算用

def gcd(a, b):
  if b > a: a,b = b,a
  #これでa >= bになったので、互除法適用可
  if a % b == 0: return b
  else: return gcd(b, a % b)
  
#cfl: cumsum from left
#[0]~[N-1] 
#cfl[0]は計算不要（gcdでなくgd(A0)=A0でいいから）
cfl = []
cfl.append(A[1]) #A[1]位置のcflはcfl[0]=A[1]
for i in range(2, N): #残りの2~N-1位置について
#あわせて1~N-1位置をcflに格納した
#2~N-1はAの添字なので注意
  cfl.append(gcd(cfl[i-2], A[i]))
  
#cfr: cumsum from right
#[0]~[N-1] 右端は0, 左端はN-1で取り出す
cfr = []
cfr.append(A[N]) #A[N]位置のcfrはcfr[0]=A[N]
for i in range(N-1, 1, -1): #残りの2~N-1位置について
#あわせて2~N位置をcfrに格納した
#N-1~2について。やはりAの添字なので注意
  cfr.append(gcd(A[i], cfr[abs(i-N+1)]))


#maxをansにメモしながら取り除くべき箇所を探す
ans = max(cfl[-1], cfr[-1]) #端っこを取り除いた場合
for nowcfl, nowcfr in zip(cfl[0:-1],cfr[::-1][1:]):
#N=2(cfl, cfrの要素数1)のときは0と-1が一致する
#→よって実行されないので問題なし
  ans = max(ans, gcd(nowcfl, nowcfr))

print(ans)

Measured memory_bytes: 14436
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    input();
   }
   static void input()
   {
     Scanner sc = new Scanner(System.in);
     
     int n = sc.nextInt();
     
     int m = sc.nextInt();
     
     int a[][] = new int[n][m];
     
     int b[] = new int[m];
     
     for(int i = 0;i < n;i ++)
     {
       for(int j = 0;j < m;j ++)
       {
         a[i][j] = sc.nextInt();
       }
     }
     for(int i = 0;i < m;i ++)
     {
       b[i] = sc.nextInt();
     }
     output(a,b,n,m);
   }
   static void output(int a[][],int b[],int n,int m)
   {
     int answer;
     
     for(int i = 0; i < n; i ++)
     {
       answer = 0;
       
       for(int j = 0; j < m; j ++)
       {
         answer += a[i][j] * b[j];
       }
       System.out.println(answer);
     }
   }
 }




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 H, N;
	cin >> H >> N;
	vector<int64> A(N), B(N);
	REP(i, N) cin >> A[i] >> B[i];
	auto dp = make_v<int64>(N+1, H+1);
	fill_v<int64>(dp, INF_LL);
	dp[0][H] = 0;
	REP(i, N) {
	  for (int64 j = H; j >= 0; j--) {
	    chmin(dp[i+1][j], dp[i][j]);
	    chmin(dp[i][max((int64)0, j-A[i])], dp[i][j] + B[i]);
	  }
	}
	cout << dp[N][0] << endl;
}


Measured memory_bytes: 78592
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

typedef struct{
	double x, y;
}point;

double dist(point a, point b){
	return sqrt(pow(a.x-b.x, 2) + pow(a.y-b.y, 2));
}

int main(){
	point p[20];
	int n=0;
	double s;

	while( scanf(" %lf,%lf", &p[n].x, &p[n].y) != EOF) ++n;

	for(int i=1; i<=n-2; ++i){
		double a=dist(p[0], p[i]), b=dist(p[0], p[i+1]), c=dist(p[i], p[i+1]); 
		double z=(a+b+c)/2.0;
		s+=sqrt(z*(z-a)*(z-b)*(z-c));
	}

	printf("%lf\n", s);

	return 0;
}

Measured memory_bytes: 1236
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    vector<pii> pos(n);
    rep(i, n){
        int x, y; cin >> x >> y;
        pos[i] = {x, y};
    }

    map<pii, int> mp;
    rep(i, n){
        rep(j, n){
            if(i == j) continue;
            int x = pos[i].first - pos[j].first;
            int y = pos[i].second - pos[j].second;
            pii p{x,y}; mp[p]++;
        }
    }
    int mx = 0;
    for(auto m: mp){
        chmax(mx, m.second);
    }
    int res = n - mx;
    cout << res << ln;
}

Measured memory_bytes: 384
n=int(input())
w=list(map(int,input().split()))
goukei=sum(w)
ans=goukei
wk=0
for i in range(n):
  wk+=w[i]
  sa=abs(goukei-2*wk)
  if sa<=ans:
    ans=sa
  else:
    break
print(ans)

Measured memory_bytes: 3060
import math
ABCDE = [input() for _ in range(5)]
ans = 0
lastorder=float('INF')
_1ketaABCDE = [int(x[-1]) for x in ABCDE]
for i in range(1,10):
    if i in _1ketaABCDE:
        lastorder = _1ketaABCDE.index(i)
        break
for i,x in enumerate(ABCDE):
    if i == lastorder:
        ans += int(x)
    else:
        ans += math.ceil(int(x)/10)*10
print(ans)

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

int need[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vi v;
string memo[10001] = {};

string dfs(int unused)
{
    if(unused == 0)        return "";
    if(memo[unused] != "") return memo[unused];
    
    string rec = "";

    for(int i = 0; i < v.size(); i++) {
	if(unused - need[v[i]] < 0) continue;

	string tmp = dfs(unused - need[v[i]]);
	if(tmp == "X") continue;
	    
	tmp = (char)('0' + v[i]) + tmp;
	
	if(rec.size() == tmp.size()) {
	    if(rec < tmp) rec = tmp;
	} else {
	    if(rec.size() < tmp.size()) rec = tmp;
	}
    }
    
    return memo[unused] = (rec == "" ? "X" : rec);
}

int main()
{
    int n, m;
    int a[11];
    
    ci >> n >> m;
    rep(i, m) ci >> a[i];

    sort(a, a + m, greater<int>());

    bool exist[10] = {};
    rep(i, m) {
	if(exist[need[a[i]]]) continue;
	exist[need[a[i]]] = true;
	v.pb(a[i]);
    }
    
    co << dfs(n) << en;
    
    return 0;
}




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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
string s;
int ans;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>s;
	rep0(i,s.size()-1){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    T=I()
    import heapq
    from collections import defaultdict
    inf=10**18+1
    for _ in range(T):
        #print("---")
        L=[0]*4
        N,L[0],L[1],L[2],L[3]=MI()
        LL=[2,3,5]
        dd = defaultdict(lambda: inf)
        dd[0]=0
        q=[(0,N,1)]#cost，数字，+-1を使えるか
        heapq.heapify(q)
        ans=L[3]*N
        while True:
            cost,now,flag=heapq.heappop(q)
            if now==0:
                ans=cost
                break
            if cost>ans:
                break
            ans=min(ans,cost+now*L[3])
            
            for i in range(3):
                if now%LL[i]==0:
                    nxt=now//LL[i]
                    ncost=cost+L[i]
                    if ncost<dd[nxt]:
                        dd[nxt]=ncost
                        heapq.heappush(q,(ncost,nxt,1))
            
            if flag:
                for k in range(1,5):
                    for pm in [1,-1]:
                        nxt=now+k*pm
                        ncost=cost+L[3]*k
                        if ncost<dd[nxt]:
                            dd[nxt]=ncost
                            heapq.heappush(q,(ncost,nxt,0))
                    
        print(ans)
                
                    
            
        
        
        
        
        
        

main()


Measured memory_bytes: 88304
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *a = map(int, read().split())
a.sort()

A = [0] * (10**5 + 1)
for i in a:
    A[i] += 1
cnt = 0
for i in range(1, 10**5 - 1):
    cnt = max(cnt, A[i - 1] + A[i] + A[i + 1])
print(cnt)


Measured memory_bytes: 21404
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) a[i] = in();
    VI b(a);
    REP(i,n){
        a[i] += i;
        b[i] = i - b[i];
    }
    ll ans = 0;
    map<int, ll> mp;
    REP(i,n){
        ans += mp[b[i]];
        mp[a[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27500
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X = int(readline())
    if X<1200:
        print('ABC')
    else:
        print('ARC')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,k;
    cin >> a >> b >> k;
    if(a>=k){
        cout << a-k << " " << b << endl;
    }else if(b>=k-a){
        cout << 0 << " " << b - k + a << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
typedef long long ll;
bool judge(string s)
{
  int siti = 0, go = 0, san = 0;
  rep(i, 0, s.size())
  {
    if (s[i] == '7')
      siti++;
    if (s[i] == '5')
      go++;
    if (s[i] == '3')
      san++;
  }
  if (siti && go && san)
    return true;
  else
    return false;
}

int main()
{
  int N;
  cin >> N;
  string nn = to_string(N);
  int len = nn.size();
  set<string> o = {"3", "5", "7"};
  set<string> s;
  set<string> ss;
  while (o.size())
  {
    auto itr = o.begin();
    string tmp = *itr;
    if (tmp.size() == len)
      s.insert(tmp);
    else
    {
      rep(i, 0, 3)
      {
        char h = '3';
        h += 2 * i;
        o.insert(h + tmp);
      }
    }
    o.erase(*itr);
    if (tmp.size() >= 3)
      ss.insert(tmp);
  }
  int ans = 0;
  vector<string> v;
  for (auto itr = ss.begin(); itr != ss.end(); itr++)
  {
    int num = stoi(*itr);
    if (judge(*itr))
      v.push_back(*itr);
  }
  vector<int> vi(v.size());
  rep(i, 0, v.size())
      vi[i] = stoi(v[i]);
  sort(vi.begin(), vi.end());
  ans = upper_bound(vi.begin(), vi.end(), N) - vi.begin();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4352
import java.util.Scanner;
 
public class Main {
 
    static boolean[] botai = new boolean[1000000];  //?´???°???false
    static{
        for (int i = 2; i <= 999999; i++) {
            if (botai[i])
                continue;
            for (int j = 2; i*j <= 999999; j++) {
                botai[i*j] = true;
            }
        }
    }
 
    private static int sl(int n) {
        int cou = 0;
 
        for (int i = 2; i <= n; i++) {
            if (!botai[i])
                cou++;
        }
 
        return cou;
    }
 
    public static void main(String[] args) {
        
    	Scanner scan = new Scanner(System.in);
 
        while(scan.hasNext()){
            System.out.println(sl(scan.nextInt()));
        }
    }
 
}

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

int main(void)
{
char s[4];
gets(s);
if(strchr(s, 'a')!=NULL&&strchr(s, 'b')!=NULL&&strchr(s, 'c')!=NULL)
{
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
 
	if (c*2>=a+b){
		cout << a*x + b*y << endl;
	}else {
		int ans = min(x,y)*2*c;
		if (x>y && a<=2*c){
			ans += (x-y)*a;
		}else if (x>y){
			ans += (x-y)*c*2;
		}else if (x<y && b<=2*c){
			ans += (y-x)*b;
		}else if (x<y){
			ans += (y-x)*c*2;
		}
		cout << ans << endl;
	}
 
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int n;
    cin >> n;
    ll a;
    map<int,int>count;
    rep(i,n){
        cin >> a;
        count[a]+=1;
        if(count[a]==2){
            cout << "NO";
            return 0;
        }
    }


    cout << "YES";
    return 0;
}

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

int main(){
  int n;
  int a = 0;
  int b = 0;
  cin >> n;
  string str1, str2;
  for(int i=0; i<n; i++){
    cin >> str1 >> str2 ;
    if ( str1 == str2 ) {
        a = a+1, b= b+1;
    }
    else if ( str1 < str2 ){
        b = b+3;
    }
    else if ( str1 > str2 ) {
        a = a+3;
    }
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3184
from heapq import heapify, heappush, heappop
def dijkstra(S, N, Edge):
    # S: start vertex
    # N: number of vertices
    # Edge: adjacent list [node, cost]
    
    INF = 10**20
    dist = [INF]*N
    dist[S] = 0
    que = [(0, S)]
    heapify(que)
    
    while que:
        c, v = heappop(que)
        if dist[v] < c: continue

        for nv, nc in Edge[v]:
            if c+nc < dist[nv]:
                dist[nv] = c+nc
                heappush(que, (c+nc, nv))
    
    return dist


import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N,X,Y = map(int,input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
    edge[i].append((i+1,1))
    edge[i+1].append((i,1))
edge[X-1].append((Y-1,1))
edge[Y-1].append((X-1,1))

ans = [0]*N
for i in range(N):
    dist = dijkstra(i, N, edge)
    for j in range(i+1,N):
        ans[dist[j]] += 1
for k in ans[1:]:
    print(k)




Measured memory_bytes: 84572
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int a,b,k; cin >> a >> b >> k;
    int n = min(a,b),cnt = 0; 
    for(int i = n; i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            cnt++;
            if(cnt == k){
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
#define MOD 1e9+7
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] ={-1,+1,0,0,+1,-1,+1,-1};
ll dy[] ={0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
bool vis[mx];
vi adj[mx];
int main()
{
    speed();
    ll a,b,c,d,x=0,i;
    cin>>a>>b;
    double ans = 0.0;
    for(i=0;i<a;i++)
    {
        cin>>c>>d;
        ans = (c*c)+(d*d);
        ans = sqrt(ans);
        //cout<<ans<<endl;;
        if(ans<=b)
            x++;
    }
    cout<<x<<endl;
}


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

ll n, a[100100], all, ans, save;

int main(){
    cin >> n;
    rep(i,n) cin >> a[i], all ^= a[i];
    rep(i,n) a[i] &= ~all;
    ll rank = 0;
    rrep(i,60){
        for (save = rank; save < n; save++) if (a[save] & (1ll<<i)) break;
        if (save == n) continue;
        if (save > rank) a[rank] ^= a[save];
        rep(j,n) if (j != rank) if (a[j] & (1ll<<i)) a[j] ^= a[rank];
        rank++;
    }
    rep(i,n) ans ^= a[i];
    cout << ans * 2 + all << endl;
}

Measured memory_bytes: 4376
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+4;
int prime[N<<1],tot;
bool vis[N<<1];
inline void linear_shaker(int lim) {
	vis[1]=true;
	for (register int i=2;i<=lim;++i) {
		if (!vis[i]) prime[++tot]=i;
		for (int j=1;j<=tot&&i*prime[j]<=lim;++j) {
			vis[i*prime[j]]=true;
			if (i%prime[j]==0) break;
		}
	}
}
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int main() {
//	freopen("in.txt","r",stdin);
	linear_shaker(2e5);
	int x=read(),id=lower_bound(prime+1,prime+tot+1,x)-prime;
	printf("%d\n",prime[id]);
	return 0;
}

Measured memory_bytes: 4000
#include<iostream>
#include<algorithm>

using namespace std;

int semi[51][51], dp[51][51];

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			char c;
			cin >> c;
			semi[i][j] = c - '0';
		}
	}
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if (i == 1 && j != 1) {
				dp[i][j] = semi[i][j] + dp[i][j - 1];
			}
			else if (j == 1 && i != 1) {
				dp[i][j] = semi[i][j] + dp[i - 1][j];
			}
			else if (j != 1 && i != 1) {
				dp[i][j] = std::min(dp[i - 1][j] + semi[i][j], dp[i][j - 1] + semi[i][j]);
			}
		}
	}
	cout << dp[h][w] << endl;
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
#define lp(i,n) for(ll i = 0;i < ll(n);i++)
#define rlp(i,n) for(ll i = ll(n);i >= 0;i--)
#define rg(i,a,b) for(ll i = ll(a);i <= ll(b);i++)
#define wh(t) while(t)
#define re return
#define pb push_back
#define sz(s) (ll)(s.size())
#define fx(n) fixed<<setprecision(n)
#define NeverGiveUp ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
/*freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);*/
using namespace std;
/*ll mx = INT_MIN;
ll mn = INT_MAX;*/
/*ll xd,dx[4]={1,0,-1,0};
ll yd,dy[4]={0,1,0,-1};
bool valid(ll xd,ll yd,ll n,ll m){return xd>-1&&xd<n&&yd>-1&&yd<m;}*/
const int sz = 1e7+5;
const ll md = 1e9+7;
//ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
ll n,ans,a[sz];
int main()
{
    NeverGiveUp
    cin>>n;
    rg(i,1,n){
        for(ll j=0;j<=n;j+=i){
            a[j]++;
        }
    }
    rg(i,1,n){
        ans+=i*a[i];
    }
    cout<<ans;
    re 0;
}


Measured memory_bytes: 81664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################


N, W = map(int, input().split())
w = [0] * N
v = [0] * N

for i in range(N):
    a, b = map(int, input().split())
    w[i] = a
    v[i] = b

dp = [ [0 for _ in range(W+1)] for _ in range(N+1) ]

for i  in range(N):
    for sum_w in range(W+1):
        if sum_w - w[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-w[i]] + v[i])

        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

print(dp[N][W])


Measured memory_bytes: 171656
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int prime(int x){
    if(x<2)
        return 0;
    for(int i=2;i*i<=x;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2)%MOD;
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a % MOD * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}
int check(int x){

}
int ternary(int s,int e){
    int mid,mid2;
    while(s+3<e){
        mid=s+(e-s)/3;
        mid2=s+(e-s)/3*2;
        if(mid>=mid2)
            e=mid2;
        else{
            s=mid;
        }
    }
    int mx=0;
    while(s<e){
        mx=max(mx,check(s));
        s++;
    }
    return mx;
}
int binary(int s,int e){
    int mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}

int n;
pair<pair<string,int>,int> arr[110];
bool comp(pair<pair<string,int>,int> x,pair<pair<string,int>,int> y){
    return (x.f.f<y.f.f?1:(x.f.f==y.f.f?(x.f.s>y.f.s?1:0):0));
}
in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>arr[i].f.f>>arr[i].f.s;
            arr[i].s=i+1;
        }
        sort(arr,arr+n,comp);
        for(int i=0;i<n;i++){
            cout<<arr[i].s<<endl;
        }
    }
    RETURN;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int n;
    cin >> n;
    vector<string> w(n);
    rep(i, n) cin >> w[i];

    int flag = 1;

    rep(i, n-1){
        if (w[i].back() != w[i+1].front()) flag = 0;
    }

    for (int i=0; i < n-1; i++){
        for (int j=i+1; j < n; j++){
            if (w[i] == w[j]) flag = 0;
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}





//              g++ -std=c++1z

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,m,k,i,j,num,cards[2][201],before=0,after=1;
    scanf("%d%d",&n,&m);
    num = n*2;
    for(i=1; i<=num; i++){
        cards[0][i]=i;
    }
    for(i=0; i<m; i++){
        scanf("%d",&k);
        if(k==0){
            for(j=1; j<=n; j++){
                cards[after][j*2-1]=cards[before][j];
                cards[after][j*2]=cards[before][j+n];
            }
        }else{
            cards[before][0]=cards[before][num];
            for(j=1; j<=num; j++){
                cards[after][j]=cards[before][(j+k)%num];
            }
        }
        if(before==0){
            before=1;
            after=0;
        }else{
            before=0;
            after=1;
        }
    }
    for(i=1; i<=num; i++){
        printf("%d\n",cards[before][i]);
    }
    return 0;
}

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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rrep(i,beg,end)   for (auto i=(beg);i>=(end);i--)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
using pii = pair<int, int>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
    }
    double sum = accumulate(all(a), 0.0l, [](double acc, ll x) { return acc + 1/double(x); });
    cout << 1 / sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    int cnt[2] = {};
    REP(i, N) {
        if (S[i] == '0') {
            cnt[0]++;
        } else {
            cnt[1]++;
        }
    }
    cout << min(cnt[0], cnt[1]) * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int n, max1 = 200000, max2 = 200001;
    int a[200002] = {};
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        if(a[max1] <= a[i]){
            max2 = max1;
            max1 = i;
            continue;
        }
        if(a[max2] < a[i]) max2 = i;
    }
    for(int i = 0; i < n; i++){
        printf("%d\n", (i == max1 ? a[max2] : a[max1]));
    }
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e7+1;
 
typedef long long ll;
typedef long double ld;

vector<ll> dd(N);

void findDivisors(ll n) 
{ 
    for (ll i = 1; i <= n; i++) { 
        for (ll j = 1; j * i <= n; j++) 
            dd[i * j]++; 
    } 
} 
void test_case()
{
    ll n,i,j;
    cin >> n;
    ll ans = 0;
    findDivisors(n);
    f(i,1,n+1)
    {
        ans = ans + i * (dd[i]);
    }

    cout << ans << '\n';
    
}
 
int32_t main()
{
    IOS(); 
  
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 81236
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
typedef pair<int,int> pii;
vector<pii> ans;
int n;
int main(){
	ios::sync_with_stdio(false);
	int i,j;
	cin>>n;
	if(n&1){
		for(i=1;i<n;i++)
			ans.push_back(make_pair(i,n));
		n--;
	}
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			if(i+j!=n+1)
				ans.push_back(make_pair(i,j));
	cout<<(int)ans.size()<<endl;
	for(i=0;i<(int)ans.size();i++)
		cout<<ans[i].first<<' '<<ans[i].second<<endl;
	return 0;
}

Measured memory_bytes: 3724
n=int(input())
A=list(map(int,input().split()))
D=[abs(A[0])]
for i in range(n-1):
    D.append(abs(A[i+1]-A[i]))
D.append(abs(A[-1]))
s=sum(D)
for i in range(n):
    c=s
    c-=D[i]+D[i+1]
    if i==0:
        c+=abs(A[1])
    elif i==n-1:
        c+=abs(A[-2])
    else:
        c+=abs(A[i+1]-A[i-1])
    print(c)

Measured memory_bytes: 14172
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
	        String N = scan.next();


	        //23456
	        //123456
	        long sum = 0L;
	        if(N.length() ==1) {
	        	System.out.println(N);
	        	return;
	        }
	        if(N.length()%2 ==1) {
	        	//sum += Integer.parseInt( N.substring(1, N.length()))+1;
	        	sum += Long.parseLong( N.substring(1, N.length()))+1  + (Long.parseLong( N.substring(0, 1))-1)* (long)Math.pow(10, N.length()-1);
	        }

	        long n = Long.parseLong(N)/10;

	        while(n>0) {
	        	int digit = String.valueOf(n).length();
	        	if(digit % 2 ==1) {
	        		sum+= (long)(Math.pow(10, digit) - Math.pow(10, digit-1) );
	        	}
	        	n /=10;

	        }
	       	System.out.println(sum);

	       	scan.close();
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

bool IsKaibun(char S[], int l){
	for(int i = 0; i < l/2; i++){
		if(S[i] != S[l-1-i]){
			return false;
		}
	}
	
	return true;
}

int main()
{
	char S[100];
	scanf("%s", S);
	
	int N = strlen(S);
	
	if(IsKaibun(S, N) && IsKaibun(S, (N-1)/2) && IsKaibun(&S[(N+3)/2-1], N-(N+3)/2+1)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

using namespace std;

long long sum(long long target){
	long long ret = 0, tmp, division = 10;
	while(target != 0){
		tmp = target % division;
		ret += tmp / (division / 10);
		division *= 10;
		target -= tmp;
	}
	return ret;
}

int main(int argc, char* argv[]){
  long long s, n;
  cin >> n;
  s = sum(n);
  if(n % s == 0){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N,M,X = gets.split.map(&:to_i)
A = gets.strip.split.map(&:to_i)
a = 0
b = 0
for i in 0..X
    if A.include?(i)
        a += 1
    end
end
for i in X..N
    if A.include?(i)
        b += 1
    end
end

if a < b
    puts a 
else
    puts b
end


Measured memory_bytes: 1788
/*
TEMPLATE
by.YXH_XianYu
   2018.7.2
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define rep(i,j,k) for(int i=j,lim=k;i<=lim;i++)
#define MXN 1000


int ans=0,
	n;
char
	s[MXN];

int main(){
	//freopen("TEMPLATE.in","r",stdin);
	//freopen("TEMPLATE.out","w",stdout);

	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n)
			 if(s[i]=='C' && ans==0){
			ans=1;
		}else if(s[i]=='F' && ans==1){
			ans=2;
			break;
		}
	if(ans==2)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


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

namespace IO {
    const int maxn(1 << 21 | 1);

    char ibuf[maxn], *iS, *iT, c;
    int f;

    inline char Getc() {
        return iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++)) : *iS++;
    }

    template <class Int> inline void In(Int &x) {
        for (f = 1, c = Getc(); c < '0' || c > '9'; c = Getc()) f = c == '-' ? -1 : 1;
        for (x = 0; c >= '0' && c <= '9'; c = Getc()) x = (x << 1) + (x << 3) + (c ^ 48);
        x *= f;
    }
}

using IO :: In;

const int maxn(305);
const int mod(1e9 + 7);

int n, m, l[maxn], x[maxn], first[maxn], nxt[maxn], ans, f[maxn][maxn][maxn];

inline void Inc(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

inline int Check(int r, int l1, int l2) {
	for (int i = first[r]; i; i = nxt[i]) {
		int cnt = (l1 >= l[i]) + (l2 >= l[i]) + 1;
		if (cnt != x[i]) return 0;
	}
	return 1;
}

int main() {
	In(n), In(m);
	for (int i = 1, r; i <= m; ++i) {
		In(l[i]), In(r), In(x[i]);
		nxt[i] = first[r], first[r] = i;
	}
	f[0][0][0] = 1;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k <= n; ++k)
				if (f[i][j][k]) {
					int r = max(i, max(j, k)) + 1;
					if (r > n) {
						Inc(ans, f[i][j][k]);
						continue;
					}
					if (Check(r, j, k)) Inc(f[r][j][k], f[i][j][k]);
					if (Check(r, i, k)) Inc(f[i][r][k], f[i][j][k]);
					if (Check(r, i, j)) Inc(f[i][j][r], f[i][j][k]);
				}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 112896
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S;
  int K;
  cin>>S>>K;
  for(int i=0;i<S.size();i++){
    if(('z'-S[i]+1)%26<=K){
      K-=('z'-S[i]+1)%26;
      S[i]='a';
    }
  }
  S[S.size()-1]='a'+(S[S.size()-1]-'a'+K)%26;
  cout<<S<<endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define in long long

in n;
long long k;
vector<vector<in>>a;
vector<vector<in>> DP;
const in inf = (in)1e9 + 7;

vector<vector<in>> mult(vector<vector<in>>& a, vector<vector<in>>& b)
{
	vector<vector<in>> answer;
	answer.resize(n);
	for (in i = 0; i < n; i++) answer[i].resize(n, 0);
	for (in i = 0; i < n; i++)
	{
		for (in j = 0; j < n; j++) // calculate answer[i][j]
		{
			for (in k = 0; k < n; k++)
				answer[i][j] = (answer[i][j]+(a[i][k] * b[k][j])%inf)%inf;
		}
	}
	return answer;
}

int main()
{
	cin >> n >> k;
	a.resize(n);
	for (in i = 0; i < n; i++)
	{
		a[i].resize(n);
		for (in j = 0; j < n; j++)
			cin >> a[i][j];
	}

	// use matrix exponent to calculate number of paths (kth exponent of adj matrix)
	vector<vector<in>> prod;
	prod.resize(n);
	for (in i = 0; i < n; i++) prod[i].resize(n);
	for (in i = 0; i < n; i++) prod[i][i] = 1;

	while (k != 0)
	{
		if (k & 1)
			prod = mult(prod, a);
		a = mult(a, a);
		k = k >> 1;
	}

	in total = 0;
	for (in i = 0; i < n; i++)
	{
		for (in j = 0; j < n; j++)
			total = (total + prod[i][j]) % inf;
	}
	cout << total << endl;
}
	/*
	// memory use is k*n (can be reduced to k); computation k*n*n too much
	//2D DP[len][i] mean the total number of path with length of len that stops at ith node
	// to simulate, do k steps backward
	//DP[len][i] is equal to the sum of all DP[len-1][j] where there is a directed path from j to i
	DP.resize(k + 1);
	for (in i = 1; i < k + 1; i++)
	{
		DP[i].resize(n, 0);
	}
	DP[0].resize(n, 1);
	
	for (in len = 1; len < k + 1; len++)
	{
		for (in i = 0; i < n; i++)
		{
			for (in j = 0; j < n; j++)
			{
				if(a[j][i])
					DP[len][i] = (DP[len][i] + DP[len - 1][j])%inf;
			}
		}
	}

	in total = 0;
	for (in i = 0; i < n; i++)
		total = (total + DP[k][i]) % inf;
	cout << total << endl;
	*/


Measured memory_bytes: 3680