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

#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define i64 long long int
#define MEM(a,x) memset(a,x,sizeof(x))
#define INF 1000000000
#define mod 998244353

using namespace std ;

#define maxn 1000005

i64 x[maxn] , mn[maxn] , dp[maxn] ;
deque< pair<i64,i64> > dq ;

int main()
{
    i64 i , j , k , l , n , m , e , t ;

    scanf("%lld %lld %lld",&n,&e,&t) ;
    for(i=1; i<=n ; i++) scanf("%lld",&x[i]) ;

    x[0] = 0 ; x[n+1] = e ;

    dp[0] = 0 ;
    mn[0] = -x[0]-2*x[1] + dp[0] ;
    dq.push_front( mp(0,0) ) ;

    i64 last = 0 ;

    for(i=1 ; i<=n ; i++)
    {
        while( last < i && 2*(x[i]-x[last+1]) > t )
        {
            if( !dq.empty() && dq.back().yy==last ) dq.pop_back() ;
            last++ ;
        }
        dp[i] = dp[i-1] + x[i]-x[i-1] + t ;
        if(last>0) dp[i] = min( dp[i] , 3*x[i] + mn[last-1] ) ;
        if( !dq.empty() ) dp[i] = min( dp[i] , x[i]+dq.back().xx+t ) ;

        mn[i] = min( mn[i-1] , dp[i]-x[i]-2*x[i+1] ) ;

        while( !dq.empty() && dq.front().xx >= dp[i]-x[i] ) dq.pop_front() ;
        dq.push_front( mp( dp[i]-x[i],i ) ) ;
    }

 //   for(i=1 ; i<=n ; i++) printf("%lld\n",dp[i]) ;

    printf("%lld\n",dp[n]+x[n+1]-x[n]) ;

    return 0 ;
}
/*
4 20 3
3 5 14 19
*/


Measured memory_bytes: 9984
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))

lst = []
for i in range(n):
    lst_l = a[:i+1]
    lst_r = b[i:]
    cnt = 0
    for j in range(len(lst_l)):
        cnt += lst_l[j]
    for j in range(len(lst_r)):
        cnt += lst_r[j]
    lst.append(cnt)
lst.sort()
print(lst[-1])

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

using namespace std;
using ll = long long;


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

    int i = n;
    for(; i < 1000; i++){
        string s = to_string(i);
        if(s[0] == s[1] && s[1] == s[2]){
            cout << i << endl;
            return 0;
        }

    }
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;


ll gcd(int x,int y){
  if(y==0)return x;
  return gcd(y, x%y);
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n,m;
  cin>>n>>m;
  if(n==0||m==1){
    cout<<0<<endl;
    return 0;
  }
  ll ret = n;
  if(n>=m){
    n = n % m;
    ret = min(ret, n);
  }
  ret = min(ret, m-n);
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int w,h;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
char maze[60][60];
int area_w[60][60];
int area_b[60][60];
int white=0,black=0;
void bfs1(int a,int b){ //black
    queue<pair<int,int>> q;
    q.push({a,b});
    bool check=0;
    while(!q.empty()){
        int inow=q.front().first,jnow=q.front().second;
        q.pop();
        for(int i=0;i<4;i++){
            int inew=inow+dx[i],jnew=jnow+dy[i];
            if(inew<h && inew>-1 && jnew<w && jnew>-1 && area_b[inew][jnew]==0 && maze[inew][jnew]=='.' ){
                area_b[inew][jnew]=1;
                q.push({inew,jnew});
            }
        }
    }
}

void bfs2(int a,int b){ //white
    queue<pair<int,int>> q;
    q.push({a,b});
    bool check=0;
    while(!q.empty()){
        int inow=q.front().first,jnow=q.front().second;
        q.pop();
        for(int i=0;i<4;i++){
            int inew=inow+dx[i],jnew=jnow+dy[i];
            if(inew<h && inew>-1 && jnew<w && jnew>-1 && area_w[inew][jnew]==0 && maze[inew][jnew]=='.' ){
                area_w[inew][jnew]=1;
                q.push({inew,jnew});
            }
        }
    }
}

int main(){
    while(1){
        cin>>w>>h;
        white=0;
        black=0;
        if(w==0 && h==0) break;
        for(int i=0;i<60;i++){
            for(int j=0;j<60;j++){
                area_w[i][j]=0;
                area_b[i][j]=0;
                maze[i][j]='0';
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>maze[i][j];
            }
        }
        /*
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<maze[i][j];
            }
            cout<<endl;
        }*/
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(maze[i][j]=='B') bfs1(i,j);
                else if(maze[i][j]=='W') bfs2(i,j);
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(area_w[i][j]==1 && area_b[i][j]==0) white++;
                if(area_w[i][j]==0 && area_b[i][j]==1) black++;
            }
        }/*
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<area_b[i][j];
            }
            cout<<endl;
        }
        //cout<<endl;
        /*for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<area_w[i][j];
            }
            cout<<endl;
        }*/
        cout<<black<<" "<<white<<endl;
        //cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3160
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = sc.next().ToCharArray();
        int a = 0;
        int b = 0;

        for (int i = 0; i < S.Length; i++) {
            if (S[i] == '0') {
                if (i % 2 == 0) {
                    a++;
                } else {
                    b++;
                }
            } else {
                if (i % 2 == 0) {
                    b++;
                } else {
                    a++;
                }
            }
        }
        WriteLine(Math.Min(a, b));
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

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

    public long nextLong() {
        return long.Parse(next());
    }

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

    public double nextDouble() {
        return double.Parse(next());
    }

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

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11872
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct food{
    int a;
    int b;
};

int main(){
    // CFS;
    int n, t;
    cin >> n >> t;
    vector<food> f(n);
    rep(i, n){
        cin >> f[i].a >> f[i].b;
    }
    sort(all(f), [](food &l, food &r){
        return l.a < r.a;
    });
    int ans = 0;
    mti dp(n+1, vi(t, 0));
    rep(i, n){
        per(j, t){
            dp[i+1][j] = dp[i][j];
            if(j >= f[i].a) dp[i+1][j] = max(dp[i+1][j], dp[i][j - f[i].a] + f[i].b);
        }
    }
    int ma = 0;
    per(i, n+1){
        per(j, t){
            ans = max(ans, dp[i][j] + ma);
        }
        ma = max(ma, f[i-1].b);
    }

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

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

struct flower {
    int height;
    int beauty;
};

ll maxBeauty(vector<flower>& v, int n) {
    vector<ll> dp(n + 1);
    map <ll, ll> cache;
    dp[1] = v[1].beauty;
    cache[v[1].height] = dp[1];
    ll ans = dp[1];
    for (int i = 2; i <= n; i++) {
        dp[i] = v[i].beauty;
        auto it = cache.upper_bound(v[i].height);
        if (it != cache.begin()) {
            it--;
            dp[i] = dp[i] + it->second;
        }
        cache[v[i].height] = dp[i];
        it = cache.upper_bound(v[i].height);
        while (it != cache.end() && it -> second <= dp[i]) {
            auto temp = it;
            temp++;
            cache.erase(it);
            it = temp;
        }
        ans = max(ans, dp[i]);
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<flower> v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i].height;
    }
    for (int i = 1; i <= n; i++) {
        cin >> v[i].beauty;
    }
    cout << maxBeauty(v, n);
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

  int num = 0;
  int max_num = 0;
  int n;
  int A[100000];

  int x;
  cin >> x;

  num = 1;
  for (int i = 2; i <= sqrt(x); ++i) {
    for (int j = 2; ;++j) {
      int tmp = (int)pow(i, j);
      if (tmp > x) break;
      num = max(num, tmp);
    }
  }

  cout << num << endl;
  
  return 0;  
}


Measured memory_bytes: 512
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if((a>=1 && a<=9) && (b>=1 && b<=9)){
			System.out.println(a*b);
		}else{
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (S == "Rainy") {
        cout << "Sunny" << endl;
    }
    return 0;
}

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

int main() {

	int W, H, N;
	cin >> W >> H >> N;

	vector<int> x(N), y(N), a(N);

	for (int i = 0;i < N;i++) {
		cin >> x.at(i) >> y.at(i) >> a.at(i);
	}

	vector<int> C = { W,H };
	vector<int> D = { 0,0 };

	for (int i = 0;i < N;i++) {
		if (a.at(i) == 1) {
			if (D.at(0) < x.at(i)) {
				D.at(0) = x.at(i);
			}
		}
		else if (a.at(i) == 2) {
			if (C.at(0) > x.at(i)) {
				C.at(0) = x.at(i);
			}
		}
		else if (a.at(i) == 3) {
			if (D.at(1) < y.at(i)) {
				D.at(1) = y.at(i);
			}
		}
		else if (a.at(i) == 4) {
			if (C.at(1) > y.at(i)) {
				C.at(1) = y.at(i);
			}
		}
	
		
	}

	if (C.at(0) > D.at(0) && C.at(1) > D.at(1))
		cout << (C.at(0) - D.at(0)) * (C.at(1) - D.at(1));

	else
		cout << 0;


}

Measured memory_bytes: 256
def read_input():
    x, y, z = map(int, input().split())
    return x, y, z


def submit():
    x, y, z = read_input()

    # z + n (y + z) < xとなる最大のnを見つければよい
    # n < (x - z) / (y + z)

    print((x - z) // (y + z))

if __name__ == '__main__':
    submit()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 
#define CERR if(false) cerr

using namespace std;


int main(){

    vector<string> s;

    rep(i,3){
        string tmp;
        cin >> tmp;
        s.pback(tmp);
    }

    cout << s[0][0] << s[1][1] << s[2][2] << endl;

    return 0; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long N, M;
        public long[] LS, RS;
        public long[] A;
        public Dictionary<long, long> Dic;
        public void Run()
        {
            {
                var line = Input.ReadLongArray();
                N = line[0];
                M = line[1];
            }

            A = Input.ReadLongArray();

            LS = new long[N];
            RS = new long[N];
            for (long i = 0; i < N; i++)
            {
                LS[i] = i == 0 ? A[i] : A[i] + LS[i - 1];
                LS[i] %= M;
            }
            for (long i = N - 1; i >= 0; i--)
            {
                RS[i] = i == N-1 ? A[i] : A[i] + RS[i + 1];
                RS[i] %= M;
            }

            // カウント
            long ret = 0;
            long X = LS[N - 1];　// 合計の余り

            Dic = new Dictionary<long, long>();

            Dic.Add(0, 1); // 右端をとらない場合

            for (long i = N - 2; i >= 0; i--)
            {
                long T = (X - LS[i] + M) % M;
                if (Dic.ContainsKey(T))
                {
                    ret += Dic[T];
                }

                long next = RS[i + 1];
                if (!Dic.ContainsKey(next))
                    Dic.Add(next, 0);
                Dic[next]++;
            }

            // 左端をとらない場合
            {
                long T = (X - 0) % M;
                if (Dic.ContainsKey(T))
                {
                    ret += Dic[T];
                }
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 24672
n = int(input())
a = tuple(map(int,input().split()))
t = 0
mod = 10**9 + 7
at = []
for j in range(1,n):
  t += a[n-j] % mod 
  at.append(t)

ans = 0
for i in range(n-1):
  ans += at[n-2-i] *a[i]
print(ans % mod)

Measured memory_bytes: 31528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		String t = br.readLine();

		char[] S = s.toCharArray();
		char[] T = t.toCharArray();

		boolean isEqual = false;

		//O(S.len^2)
		for(int i = 0;i<S.length;i++){
			for(int j=0;j<S.length;j++){
				isEqual = true;
				if(S[(j+i)%S.length] != T[j]){
					isEqual = false;
					break;
				}

			}
			if(isEqual)break;
		}

		if(isEqual)System.out.println("Yes");
		else System.out.println("No");


	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;

  // 先頭がA以外でその次の文字と最後の文字が大文字はWA
  if (S[0] != 'A' || isupper(S[1]) || isupper(S[S.size() - 1])) {
    cout << "WA" << endl;
    return 0;
  }

  int cnt = 0;
  rep(i, 1, S.size() - 1) {
    // 大文字がC以外はWA
    if (isupper(S[i])) {
      if (S[i] != 'C') {
        cout << "WA" << endl;
        return 0;
      }
      cnt++;
    }
    // 大文字が２つ以上でWA
    if (cnt == 2) {
      cout << "WA" << endl;
      return 0;
    }
  }

  //　大文字が一つも存在しないとWA
  if (cnt == 0) {
    cout << "WA" << endl;
  } else {
    cout << "AC" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define pii pair<int,int>
#define sz(x) (int) x.size()
#define f first
#define s second
using namespace std;
const int N=1e3+2;
const int M=1e8;
bool is[N];
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x,n;
    cin>>x>>n;
    ll cur;
    for(int i=0;i<n;i++){
        cin>>cur;
        is[cur]=1;
    }
    ll mn=LLONG_MAX,ans=-1;
    for(int i=-200;i<=201;i++){
        if(i<=0 || !is[i]){
            if(abs(i-x)<mn){
                mn=abs(i-x);
                ans=i;
            }
        }
    }
    cout<<ans;
    return 0;
}
// abcd


Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[][] = new int[M][2];
		int min = Integer.MAX_VALUE;
		int max = 0;
		for(int i = 0; i < M; i++) {
			K[i][0] = sc.nextInt();
			max = Math.max(max, K[i][0]);
			K[i][1] = sc.nextInt();
			min = Math.min(min, K[i][1]);
		}
		System.out.println(Math.max(min - max + 1, 0));
	}
}


Measured memory_bytes: 88872
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::iter::once;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let n = read!(usize);
    let a = read!(i64; n);

    let mut a2 = a.iter().zip(0..).vec();
    a2.sort();

    for i in 0..n {
        if i == a2[n - 1].1 {
            println!("{}", a2[n - 2].0);
        } else {
            println!("{}", a2[n - 1].0);
        }
    }
}


Measured memory_bytes: 12660
#include <bits/stdc++.h>
using namespace std;
#define MAX_WORK_TIME 222222
 
struct Writer{
  int idx;
  int diff;
  int len;
};
 
int main(void){
  int n, m;
  while(cin >> n >> m, n | m){
    vector<Writer> writer;
    int tmp_min = MAX_WORK_TIME;
    for(int i = 0; i < n; i++){
      Writer tmp;
      tmp.idx = i+1;
      cin >> tmp.diff;
      int d = (m/tmp.diff)*tmp.diff;
      tmp.len = d;
       
      while(tmp.len - tmp.diff  > tmp_min){
    tmp.len -= tmp.diff;
      }
     
      writer.push_back(tmp);
      tmp_min = min(tmp_min, tmp.len);
    }
    /*
    for(int i = 0; i < n; i++){
      cout << writer[i].idx << " " << writer[i].diff << " " << writer[i].len << endl;
    }
    */
 
    int lenmin = MAX_WORK_TIME;
    for(int i = 0; i < writer.size(); i++){
      lenmin = min(lenmin, writer[i].len);
    }
    vector<Writer> possible_with_worktime;
    for(int i = 0; i < writer.size(); i++){
      if(writer[i].len == lenmin){
    possible_with_worktime.push_back(writer[i]);
      }
    }
    if(possible_with_worktime.size() == 1){
      cout << possible_with_worktime[0].idx << endl;
      continue;
    }
 
    int diffmin = MAX_WORK_TIME;
    for(int i = 0; i < possible_with_worktime.size(); i++){
      diffmin = min(diffmin, possible_with_worktime[i].diff);
    }
    vector<Writer> possible_with_difficulty;
    for(int i = 0; i < possible_with_worktime.size(); i++){
      if(possible_with_worktime[i].diff == diffmin){
    possible_with_difficulty.push_back(possible_with_worktime[i]);
      }
    }
    if(possible_with_difficulty.size() == 1){
      cout << possible_with_difficulty[0].idx << endl;
    }else{
      cout << n << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1244
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  $str = fgets(STDIN);
  for($j = 0; $j < $W; $j++){
    $MAP[$i][$j] = $str[$j];
  }
}
$max = 0;
for($Y = 0; $Y < $H; $Y++){
  for($X = 0; $X < $W; $X++){
    if($MAP[$Y][$X] == "#")continue;
    $dist = 0;
    $map = $MAP;
    $c[] = [$Y,$X];
    $map[$Y][$X] = '#';
    while($c){
      $cc = [];
      foreach($c as list($y, $x)){
        foreach([[0,1],[1,0],[0,-1],[-1,0]] as list($dy, $dx)){
          if(isset($map[$y+$dy][$x+$dx]) && $map[$y+$dy][$x+$dx] == '.'){
            $map[$y+$dy][$x+$dx] = '#';
            $cc[] = [$y+$dy,$x+$dx];
          }
        }
      }
      if($cc)$dist++;
      $c = $cc;
    }
    $max = max($dist, $max);
  }
}
echo $max;



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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void){

    int n,k;
    scanf("%d %d",&n,&k);
    int h[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    qsort(h, n, sizeof(int), compare_int);

    long sum=0;
    if(k>=n){
        sum=0;
    }else{
        for(i=k;i<n;i++){
            sum += h[i];
        }
    }
    printf("%ld\n",sum);

    return 0;
}


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

int main()
{

    string s;
    cin>>s;
    if(s.size()==1)
    {
        cout<<"0"<<endl;
    }
    else
    {
        int k=s.size()-1,c=0;
        for(int i=0;i<(s.size()/2);i++)
        {
           if(s[i]!=s[k])
           {
               c++;
           }
           k--;
        }
        cout<<c<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    long r = ni();
    long d = ni();
    long x = ni();
    
    for (int i = 0; i < 10; i ++) {
      x = r * x - d;
      System.out.println(x);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21972
/**
 *  author: mahfuzz
 *  created: 22.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n, m; cin >> n >> m;
  
    int a = (n * (n - 1)) / 2;
    int b = (m * (m - 1)) / 2;
    
    cout << a + b << "\n";
    
        
    return 0;
}


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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B)
    cout << C << endl;
  else if (A == C)
    cout << B << endl;
  else
    cout << A << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
A.sort()
print(A[-1] - A[0
])


Measured memory_bytes: 13636
import java.io.PrintWriter;
import java.util.*;

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

        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a = scanner.nextInt();
        int b=0;
        int len = String.valueOf(a).length();
        ArrayList<Integer> list = new ArrayList<>();
        int d = (int)Math.pow(10, len - 1);

        for (int i = 1; i <= len; i++) {
            list.add(a/d);
            a %= d;
            d /= 10;
        }

        for(int i = 1; i <= len; i++) {
            int buf = list.get(i-1);
            if(buf==9){
                buf=1;
            }else if(buf==1){
                buf=9;
            }
            b += buf*(int)Math.pow(10,len-i);
        }
        
        out.println(b);
        out.flush();
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
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;
}

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;cin>>n;
    int point_a=0,point_b=0;
    vector<int> p;
    rep(i,n)
    {
        int x;cin>>x;
        p.push_back(x);
    }
    sort(p.begin(),p.end());
    bool flag = true;
    while(!p.empty())
    {
        if(flag){
            point_a += p.back();
            flag = false;
        }
        else {
            point_b += p.back();
            flag = true;
        }
        p.pop_back();
    }

    cout<<point_a-point_b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,p=0,w=0,g=0,y=0;
    scanf("%d",&n);
    char Arr[n];
    for(i=0; i<n; i++)
    {
        scanf("%s",&Arr[i]);
        if(Arr[i]=='P')
        {
            p++;
        }
        if(Arr[i]=='W')
        {
            w++;
        }
        if(Arr[i]=='G')
        {
            g++;
        }
        if(Arr[i]=='Y')
        {
            y++;
        }
    }
    if(p&&w&&g&&y)
    {
        printf("Four\n");
    }
    else
    {
        printf("Three\n");
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
s = [input() for _ in range(n)]
ans = {}
for judge in ["AC", "WA", "TLE", "RE"]:
    ans[judge] = 0
for x in s:
    ans[x] += 1
print("AC x", ans["AC"])
print("WA x", ans["WA"])
print("TLE x", ans["TLE"])
print("RE x", ans["RE"])


Measured memory_bytes: 16148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define u128 __int128
#define ss second
#define pb push_back

#define N 200010
#define MOD 1000000007

ll n, m, k;

ll bexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a;
		a *= a;
		b >>= 1;
	}
	return res;
}

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

// 	int n, m, k;
// 	cin >> n >> m >> k;
// 	if(n <= m && k <= m)
// 		cout << "Yes\n";
// 	else
// 		cout << "No\n";
// 	return 0;
// }
// int main()
// {
// 	ios::sync_with_stdio(false);
// 	cin.tie(NULL);

// 	ll n, m;
// 	cin >> n >> m;
// 	ll k1 = (n + 1) / 3, k2 = (m + 1)/ 2, k3 = (n + 1)/ 2, k4 = (m + 1) / 3;
// 	ll m1 = k1 * k2, m2 = k3 * k4;
	
// 	if(n % 3 == 1)
// 	{
// 		m1 += (m + 1)/3;
// 	}
// 	if(m % 3 == 1)
// 		m2 += (n + 1)/3;
// 	cout << max(m1, m2);
// 	return 0;
// }

int main()
{
	
	int a, b, c;
	cin >> a >> b >> c;

	int k = 0;
	for(int i = min(a, b); i > 0; --i)
	{
		if(a % i == 0 && b % i == 0)
		{
			k++;
			if(k == c)
			{
				cout << i;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
int main()
{
  int w,h,x,y,r;
  scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
  if(x+r>w)printf("No\n");
  else if(x-r<0)printf("No\n");
  else if(y+r>h)printf("No\n");
  else if(y-r<0)printf("No\n");
  else printf("Yes\n");
  return 0;
}



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

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t; 
	cin >> a >> b;
	cin >> u;
	
	if(u == s) {
		cout << a-1 << " " << b;
	} else if(u == t) {
		cout << a << " " << b-1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define N 105
int a[N];
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) 
		scanf("%d", &a[i]);
	for(int i = 1; i < n; i++) {
		for(int j = i+1; j <= n; j++) {
			if(a[i] > a[j]) {
				int t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
		}
	}
	printf("%d", a[n] - a[1]);
	return 0;
}

Measured memory_bytes: 128
#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)

int main()
{
    int n, k;
    cin >> n >> k;
    long double ans = 0;
    int i = 0;
    FOR(i,1,n+1){
        int cnt=0;
        int pnt = i;
        int kk = k;
        while(pnt<k){
            pnt *= 2;
            cnt++;
        }
        //cout << i << " " << cnt;
        ans += pow(0.5, cnt);
    }

    cout << std::setprecision(100) << ans / n << "\n";

    return 0;
}

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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin >> n >> k;
	ll h[n];
	rep(i,0,n){
		cin >> h[i];
	}
	sort(h,h+n);
	ll mini=inf;
	for(ll i=0; i<n-k+1; i++){
		mini=min(mini,h[i+k-1]-h[i]);
	}
	cout << mini;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	static Scanner sc =  new java.util.Scanner(System.in);

	public static void main(String[] args) {
		
		int n = sc.nextInt();
		
		double a = 100000;
		
		for (int x = 1 ; x <= n ; x++){
			
			a = a * (1.05) ;
			double b = a / 1000 ;
			
			BigDecimal bib = new BigDecimal (String.valueOf(b));
			b =bib.setScale(0, BigDecimal.ROUND_UP).doubleValue();
			
			a = b * 1000;
			
		}
		
		int c = (int)a;
		System.out.println(c);
	}

}

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

int main() {
	vector<char>predict(3);
	vector<char>real(3);
  	for(int i=0;i<3;i++){
        cin>>predict.at(i);
    }
    for(int i=0;i<3;i++){
      cin >> real.at(i);
    }
	int count=0;
	for (int i=0;i<3;i++){
		if (predict.at(i)==real.at(i)){
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int i=0;;i++){
        if(i&1){
            a-=d;
            if(a<=0){
                cout<<"No\n";
                break;
            }
        }
        else{
            c-=b;
            if(c<=0){
                cout<<"Yes\n";
                break;
            }
        }
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;


class UnionFind {
public:
	vector<int> parent;
	int n;
	UnionFind(int x) :parent(x, -1), n(x){}

	bool unite(int x, int y){
		x = find(x);
        y = find(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		parent[x] += parent[y];
        parent[y] = x;
		return true;
	}
	bool same(int x, int y){
        return find(x) == find(y);
    }
	int find(int x){
        return parent[x] < 0 ? x : parent[x] = find(parent[x]);
    }
	int size(int x){
        return -parent[find(x)];
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> cnt(n, 0);
    UnionFind uf(n);

    int in1, in2;
    rep(i, m){
        cin >> in1 >> in2;
        cnt[in1-1]++;
        cnt[in2-1]++;
        uf.unite(in1-1, in2-1);
    }
    rep(i, k){
        cin >> in1 >> in2;
        if(uf.same(in1-1, in2-1)){
            cnt[in1-1]++;
            cnt[in2-1]++;
        }
    }

    for(int i=0; i<n; i++){
        cout << uf.size(i) - cnt[i] - 1;
        if(i != n-1) cout << " ";
        else cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll n,C;cin>>n>>C;
    ll d[C+1][C+1];
    rep(i,1,C)rep(j,1,C)cin>>d[i][j];
    ll c[n][n];
    rep(i,0,n-1)rep(j,0,n-1)cin>>c[i][j];
    ll hoge[3][C+1];
    rep(i,0,2)rep(j,1,C)hoge[i][j]=0;
    rep(i,0,n-1)rep(j,0,n-1){
        rep(k,1,C){
            hoge[(i+j)%3][k]+=d[c[i][j]][k];
        }
    }
    ll ans=inf;
    rep(i,1,C){
        rep(j,1,C){
            rep(k,1,C){
                if(i!=j && j!=k && k!=i){
                    ans=min(ans,hoge[0][i]+hoge[1][j]+hoge[2][k]);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c;
	cin >> k;
	vector<int> v;
	v.push_back(a);v.push_back(b);v.push_back(c);
	sort(v.begin(), v.end());
	cout << v[0] + v[1] + v[2] * pow(2,k) << endl;
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

vector<int> number_of_divisors(int N) {

    vector<bool> is_prime(N, true);
    vector<int> primes;
    vector<int> n_divisors(N);
    
    n_divisors[1] = 1;
    
    FOR(i, 2, N + 1) {
        if (is_prime[i]) {
            primes.pb(i);
            n_divisors[i] = 2;
        }
        for (int p: primes) {
            ll n = i * p;
            if (n >= N) {
                break;
            }
            is_prime[n] = false;
            if (i % p == 0) {
                ll j = i / p;
                ll e = 1;
                while (j % p == 0) {
                    j /= p;
                    e += 1;
                }
                n_divisors[n] = n_divisors[i] / (e + 1) * (e + 2);
                break;
            } else {
                n_divisors[n] = n_divisors[i] * 2;
            }
        }
    }
                
    return n_divisors;
}

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

    ll N;
    cin >> N;

    auto n_divisors = number_of_divisors(N + 1);

    ll result = 0;
    FOR(i, 1, N + 1) {
        result += (ll)i * n_divisors[i];
    }
    cout << result << endl;

    return 0;
}



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

int N,A[101],B[101],a,M;

int main(void){
    cin >>N;
    rep(i,N){
        cin >> a;
        A[i+1] = A[i] + a;
    }
    rep(i,N){
        cin >> a;
        B[i+1] = B[i] + a;
    }
    
    for(int i=1;i<=N;i++){
        M = max(A[i]+B[N]-B[i-1],M);
    }
    cout << M << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char a[55][55];
int main(){
	ll h,w;cin>>h>>w;
	rep(i,h){
	  rep(j,w){
	    cin>>a[i+1][j+1];
	  }
	}
	bool flg=false;
	rep(i,h){
	  rep(j,w){
	  	if(a[i+1][j+1]=='#'){
		  	flg=false;
		    rep(k,4){
		    	if(a[i+1+dx[k]][j+1+dy[k]]=='#'){
		    		flg=true;
		    	}
		    }
		    if(flg==false){
	    		cout<<"No"<<endl;
	    		return 0;
	    	}
	    }
	  }
	}
	cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <wchar.h>

inline static void put_int(int x) {
    int s = 0;
    char f[6] = {'0', '0', '0', '0', '0', '0'};
    while (x) {
        f[s++] += x % 10;
        x /= 10;
    }

    while (s--) putc_unlocked(f[s], stdout);
}

int main() {
    int flag = 0, l = 0, r = 0, i = 0, tmp, first = 1;

    for (;(tmp = getchar_unlocked() - 'L') >= 0; i++) {
        if (tmp) {
            // if c is R
            if (flag) {
                flag = 0;

                if ((tmp = r + 1) < l) {
                    if (first) {
                        first = 0;
                    } else {
                        putchar_unlocked(' ');
                    }
                    putchar_unlocked('0');

                    for (tmp++; tmp < l; tmp++) {
                        putc_unlocked(' ', stdout);
                        putc_unlocked('0', stdout);
                    }
                }

                if (first) {
                    first = 0;
                } else {
                    putchar_unlocked(' ');
                }
                tmp = (l - r + 1) / 2 + (i - l) / 2;
                put_int(tmp);
                putchar_unlocked(' ');
                tmp = (i - r) - tmp;
                put_int(tmp);

                for (tmp = l + 1; tmp < i; tmp++) {
                    putc_unlocked(' ', stdout);
                    putc_unlocked('0', stdout);
                }
                r = i;
            }
        } else {
            // if c is L
            if (!flag) {
                flag = 1;
                l = i;
            }
        }
    }

    if ((tmp = r + 1) < l) {
        if (first) {
            first = 0;
        } else {
            putchar_unlocked(' ');
        }
        putchar_unlocked('0');

        for (tmp++; tmp < l; tmp++) {
            putc_unlocked(' ', stdout);
            putc_unlocked('0', stdout);
        }
    }

    if (first) {
        first = 0;
    } else {
        putchar_unlocked(' ');
    }
    tmp = (l - r + 1) / 2 + (i - l) / 2;
    put_int(tmp);
    putchar_unlocked(' ');
    tmp = (i - r) - tmp;
    put_int(tmp);

    for (tmp = l + 1; tmp < i; tmp++) {
        putc_unlocked(' ', stdout);
        putc_unlocked('0', stdout);
    }

    putchar_unlocked('\n');
}


Measured memory_bytes: 384