akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1000000007;
int main() {
  LL n,ans=0; cin>>n;
  vector<LL> a(n); for(LL i=0;i<n;i++) cin>>a[i];
  LL subSum=0;
  for(int i=0;i<n-1;i++){
    subSum+=a[i];
    subSum%=MOD;
    ans+=subSum*a[i+1];
    ans%=MOD;
  }
  cout<<ans;
}

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

int main()
{
  int N, L, a, sum = 0, e = 10000;
  cin >> N >> L;

  for(int i = 1; i <= N; i++){
    a = L + i - 1;
    sum += a;
    if(abs(a) < abs(e))
      e = a;
  }
  cout << sum - e << endl;
  return 0;
}

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

namespace contest_Csharp
{
    class Program
    {
        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (long i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ')
                .Select(x => long.Parse(x)).ToList();
            long A = vals[0];
            long B = vals[1];
            long N = vals[2];
            long result = 0;

            if (B>N)
            {
                result = (A / B) * N + ((A % B) * N) / B;
            }
            else
            {
                result = (A / B) * (B-1) + ((A % B) * (B-1)) / B;
            }
            Console.WriteLine(result);
        }



    }


}


Measured memory_bytes: 28192
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#include <chrono>
#include <array>
#include <random>
#include <fstream>
#include <list>


std::string yesno(bool b) {
    return b ?
    "Yes" : "No";
    // "YES" : "NO";
    // "yes" : "no";
    
}


int main() {
    std::cin.tie(0); std::ios::sync_with_stdio(false);
    std::array<std::array<int, 3>, 3> a;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            int tmp;
            std::cin >> tmp;
            a[i][j] = tmp;
        }
    }
    std::array<int, 3> ac, bc;
    ac[0] = 0;
    bool ok = true;
    for (int i = 0; i <3 ; ++i) {
        bc[i] = a[0][i] - ac[0];
        ac[i] = a[i][0] - bc[0];
    }
    for (int i = 1; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if(a[i][j] != ac[i] + bc[j]){
                ok = false;
            }
        }
        
    }
    std::cout << yesno(ok) << std::endl;
    
}


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

if N == K:
    print(1)
else:
    tmp = N - K
    ans = 1 + tmp // (K-1)

    if tmp % (K-1) != 0:
        ans += 1        
    
    print(ans)

Measured memory_bytes: 14008
import sys


def main():
    A, V = list(map(int, input().split()))
    B, W = list(map(int, input().split()))
    T = int(input())

    if W > V:
        print('NO')
        sys.exit()
    x = V - W
    c = abs(B - A)
    ans = c - x * T

    if ans <= 0:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] x=new int[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextInt();
        }
        Arrays.sort(x);
        int min=100000000;
        for(int i=x[0];i<=x[n-1];i++){
            int tmp=0;
            for(int j=0;j<n;j++){
                tmp+=Math.pow(x[j]-i,2);
            }
            if(tmp<min){
                min=tmp;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 22484
#include <stdio.h>

int main() {
	int N, Y, A, B, i, n, flg = 1, x, y, z;
	scanf("%d%d", &N, &Y);
	A = Y/1000 - N; B = 10 * N - Y/1000;
	for (i = 2 * A / 9 + 0.9; 36 * i <= 9 * A; i++) {
		y = 9 * i - 2 * A;
		n = (2 * B - y) / 9;
		if ((2 * B - y) % 9 == 0 && 9 * B <= 45 * n && 45 * n <= 10 * B) {
			x = A - 4 * i;
			z = 5 * n - B;
			flg = 0;
			break;
		}
	}
	if (flg) {
		x = -1; y = -1; z = -1;
	}
	printf("%d %d %d", x, y, z);
	return 0;
}

Measured memory_bytes: 128
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
#include<iostream>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100+5;
const ll mod = 1e9+7;

int a[maxn][maxn];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
        a[i][j] = i!=j;
    if(n&1)for(int i=1;i<=n;i++)
        a[i][n-i] = 0;
    else for(int i=1;i<=n;i++)
        a[i][n+1-i] = 0;
    printf("%d\n",n*(n-1)/2-n/2);
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
        if(a[i][j])
            printf("%d %d\n",i,j);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;
using namespace std;

void solve(int n,int m){
    int in,c[101]={0},max_n,max_j;
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            scanf("%d",&in);
            c[j]+=in;
        }
            
    
    for(int i=0;i<m;i++){
        max_n=0;
        max_j=0;
        for(int j=0;j<m;j++){
            if(max_n<c[j]){
                max_j=j;
                max_n=c[j];
            }
        }
        printf(i<m-1 ?"%d ":"%d\n",max_j+1);
        c[max_j]=0;
    }
    
    return;
}

int main(){
    int n,m;
    while(1){
        scanf("%d%d",&n,&m);
        if(n+m==0) break;
        solve(n,m);
    }
}

Measured memory_bytes: 1188
from operator import itemgetter
N = int(input())
ls = []
for i in range(N):
    s,p = input().split()
    p = int(p)
    ls.append([s,p,i+1])
ls = sorted(ls,key=itemgetter(1),reverse=True)
ls = sorted(ls,key=itemgetter(0))
for i in range(len(ls)):
    print(ls[i][2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  string s;
  cin >> s;
  
  int a=0,b=0;
  int len = s.size();
  
  rep(i,len){
    if(i%2==0){
      if(s[i]=='0') a++;
      else b++;
    }else{
      if(s[i]=='1') a++;
      else b++;
    }
  }
  
  cout << min(a,b) << endl;
  
  
  return 0;
}

Measured memory_bytes: 512
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    var in = sc.nextInt
    var i:Int = 1
    do {
      println("Case "+ i +": " + in)
      in = sc.nextInt
      i += 1
    } while ( in != 0)
  }
}

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

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

    if (a == b + c) {
        cout << "Yes" << endl;
    } else if (b == a + c) {
        cout << "Yes" << endl;
    } else if (c == a + b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  int N,W;cin>>N>>W;
  vector<LL>w(N+1),v(N+1);
  for(int i=1;i<=N;i++)cin>>w[i]>>v[i];
  LL dp[100001]={};
  for(int i=1;i<=N;i++){
    for(int j=W;j>=w[i];j--){
      dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
    }
  }
  cout<<dp[W]<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll solve(int N, vector<int>& S) {
    sort(ALL(S));
    auto used = vector<int>{S.back()};
    auto unused = S;
    S.pop_back();

    int num_of_gen = 1;

    while (SIZE(used) < (1<<N)) {
        vector<int> next_used;
        REP(i, num_of_gen) {
            auto loc = lower_bound(ALL(unused), used[i]);
            if (loc == unused.begin()) return false;
            next_used.pb(used[i]);
            next_used.pb(*(loc - 1));
            unused.erase((loc - 1));
        }
        used = next_used;
        num_of_gen *= 2;
    }
    return true;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> S((1<<N));
    REP(n, (1<<N)) cin >> S[n];

    if (solve(N, S)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 4976
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, k, a, b;
    cin >> n >> k;
    map<int, ll> counter;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        counter[a] += b;
    }
    ll acc = 0;
    for(auto p: counter) {
        acc += p.second;
        if (acc >= k) {
            cout << p.first << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 4224
a, b = map(int, raw_input().split())
def f(n):
    if n < 0 or n % 4 == 3:
        return 0
    elif n % 4 == 2:
        return n + 1
    elif n % 4 == 1:
        return 1
    else:
        return n
print f(b) ^ f(a - 1)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >>s;
  ll n = sz(s);
  vl cnt(26,0);
  rep(i,n){
    cnt[s[i]-'a']++;
  }
  ll ans = 0;
  rep(i,26){
    ans-= cnt[i]*(cnt[i]-1)/2;
  }
  ans += n*(n-1)/2;
  cout<<ans+1<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>


int main()
{
    int a, b;
    std::cin >> a >> b;

    std::cout << a / b << " " << a % b << " ";
    std::cout << std::fixed << std::setprecision(5) <<  a * 1.0 / b << std::endl;
    return 0;
}


Measured memory_bytes: 3276
def main():
    point = 0
    ab = []
    for i in range(int(input())):
        t = list(map(int, input().split()))
        ab.append(t)
    ab.sort(key=lambda x: x[1])
    for i in range(len(ab)):
        point += ab[i][0]
        # print(point, ab[i])
        if point > ab[i][1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 46944
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long left,right;
  long long com,l;
  long long n;
  long long ans;
  left = b/c - (a-1)/c;
  right = b/d - (a-1)/d;
  l = lcm(c,d);
  com = b/l - (a-1)/l;
  n = left + right - com;
  ans = (b-a+1)-n;
  cout<<ans<<endl;
  return 0;
}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100

string S;

string T[4] = {
				"dreamer",
				"eraser",
				"dream",
				"erase",
			};

int main() {
	cin >> S;

	int j = S.size();
	int ans = 0;
	while( j > 0 ) {
		int flag = 0;
		for( int i = 0; i < 4; i++ ) {
			int sz = (int)T[i].size();
			if( j - sz >= 0 && S.substr( j - sz, sz ) == T[i] ) {
				j -= sz;
				flag = 1;
				break;
			}
		}
		if( flag == 0 ) {
			ans = 1;
			break;
		}
	}

	if( ans == 0 ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 512
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

aaa = set([1,2,3])
aa = set()

a = onem()
aa.add(a)
b = onem()
aa.add(b)

print((aaa-aa).pop())








Measured memory_bytes: 38256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)

const int maxn = 105;
int n;
int a[maxn];

int get_ans(int x) {
    int ret  = 0;
    for (int i = 1; i <= n; ++i) {
        ret += (a[i] - x) * (a[i] - x);
    }
    return ret;
}

int main() {
#ifdef __APPLE__
    freopen("main.in", "r", stdin);
#endif
    scanf(" %d", &n);
    for (int i = 1; i <= n; ++i) scanf(" %d", a + i);
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= 100; ++i) {
        ans = min(ans, get_ans(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
gcd = [[0 for _ in range(200)] for _ in range(200)]
for i in range(200):
  for j in range(200):
    big = i+1
    sml = j+1
    while sml != 0:
      big,sml = sml,big%sml
    gcd[i][j] = big
#print(gcd)
ans = 0
for a in range(n):
  for b in range(n):
    for c in range(n):
      x = gcd[a][b]
      y = gcd[a][c]
      ans += gcd[x-1][y-1]
      #print(a,b,c,x,y,gcd[x][y])
print(ans)

Measured memory_bytes: 68368
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int N, K;
    cin >> N >> K;

    int minimum = 1;
    int maximum = N-K+1;

    if(K==1){
        cout << 0 << endl;
    }else{
        cout << maximum - minimum << endl;
    }



    return 0;
}

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

int main()
{
	int x[10000];
	int i = 0;
	while (true) {
		cin >> x[i];
		if (x[i] == 0) break;
		++i;
	}
	for (int n = 0; n < i; n++) cout << "Case " << n + 1 << ": " << x[n] << endl;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
int const MAX_N = 100009;
vector<int> G[MAX_N];

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

int n;
cin >> n;
rep(i,n-1) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
}

vector<int> dpf(n,-1);
queue<int> quef;
dpf[0] = 0;
quef.push(0);
while(!quef.empty()) {
    int v = quef.front(); quef.pop();
    for(int nv : G[v]) {
        if(dpf[nv] != -1) continue;
        dpf[nv] = dpf[v] + 1;
        quef.push(nv);
    }
}

vector<int> dps(n,-1);
queue<int> ques;
dps[n-1] = 0;
ques.push(n-1);
while(!ques.empty()) {
    int v = ques.front(); ques.pop();
    for(int nv : G[v]) {
        if(dps[nv] != -1) continue;
        dps[nv] = dps[v] + 1;
        ques.push(nv);
    }
}

int cntf = 0, cnts = 0;
rep(v,n) {
    if(dpf[v] <= dps[v]) cntf++;
    else cnts++;
}
if(cntf > cnts) cout << "Fennec" << endl;
else cout << "Snuke" << endl;

return 0;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...

const int maxn = 1e7+1;
vector<bool> is_prime(maxn,true);
vector<int> fact(maxn,-1);


void sieve(){
	is_prime[0] = is_prime[1] = false;
	for(int i = 2;i<maxn;++i){
		if(is_prime[i]){
			fact[i] = i;
			for(int j = 2;j*i<maxn;++j){
				is_prime[i*j] = false;
				fact[i*j] = i;
			}
		}
	}
}
	
ll calc(int n){
	map<int,int> mp;
	while(n>1){
		int f = fact[n];
		mp[f]++;
		n/=f;
	}
	ll res = 1;
	//debug() << owo(mp);
	for(auto [a,b] : mp){
		res *= (b+1);
	}
	return res;
}
	
int N;	
void test_case(){
	sieve();
	cin>>N;
	ll ans = 0;
	for(ll i = 2;i<=N;++i){
		ans += i*calc(i);
		
	}
	cout<<ans+1;
	
}





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    int crt = 0;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        if(x==crt+1) crt++;
    }
    int res = crt?n-crt:-1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
/*
    author: Salam_35
    Created at :

*/

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

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
	int n,s;
	cin >> n >> s;
    for(int i=0;i<=n;i++)
    {
    	for(int j=0;j<=n;j++)
    	{
    		if(i+j==n)
    		{
    			int legs=i*2+j*4;
    			if(legs==s)return cout<<"Yes"<<endl,0;
    		}
    	}
    }
    cout<<"No"<<endl;
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  if(a==111)
    cout << 3 << endl;
  else if(a==1 || a==10 || a==100)
    cout << 1 << endl;
  else if(a==110 || a==11 || a==101)
    cout << 2 <<endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3624
import itertools
import math
import fractions

n,k = map(int,input().split())
ans = n
s =[]
if k == 1 or n == 0 or n==k :
    print("0")
    exit()
elif n < k:
    ans = abs(n-k)
    print(min(ans,n))
    exit()

elif n > k:
    ans = n%k

while(1):
    s.append(ans)
    ans = abs(ans-k)
   # print(ans)
    if s.count(ans):
        ans=abs(ans-k)
        break

print(ans)

Measured memory_bytes: 65004
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int w, h;
    while(cin >> w >> h, w){
        vector<int> ys{0, h-1}, xs{0, w-1};
        int n;
        cin >> n;
        vector<array<int, 4>> q(n);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 2; ++j) {
                cin >> q[i][j*2] >> q[i][j*2+1];
                xs.emplace_back(q[i][j*2]);
                ys.emplace_back(q[i][j*2+1]);
            }
        }
        sort(ys.begin(), ys.end());
        ys.erase(unique(ys.begin(), ys.end()), ys.end());
        sort(xs.begin(), xs.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
        auto zy = [&ys](int y){ return lower_bound(ys.begin(),ys.end(), y) - ys.begin(); };
        auto zx = [&xs](int x){ return lower_bound(xs.begin(),xs.end(), x) - xs.begin(); };
        h = ys.size(); w = xs.size();
        vector<vector<int>> v(h, vector<int>(w, 0));
        for (int i = 0; i < n; ++i) {
            int x1 = zx(q[i][0]), y1 = zy(q[i][1]),
                    x2 = zx(q[i][2]), y2 = zy(q[i][3]);
            v[y1][x1]++; v[y1][x2]--; v[y2][x1]--; v[y2][x2]++;
        }
        for (int i = 1; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                v[i][j] += v[i-1][j];
            }
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 1; j < w; ++j) {
                v[i][j] += v[i][j-1];
            }
        }
        h--; w--;
        UnionFind uf(h*w);
        array<int, 4> dy{-1, 1, 0, 0}, dx{0, 0, -1, 1};
        int cnt = 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if(v[i][j]) continue;
                cnt++;
                for (int k = 0; k < 4; ++k) {
                    if(0 <= i+dy[k] && i+dy[k] < h && 0 <= j+dx[k] && j+dx[k] < w && !v[i+dy[k]][j+dx[k]]){
                        if(uf.unite(i*w+j, (i+dy[k])*w+(j+dx[k]))) cnt--;
                    }
                }
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}


Measured memory_bytes: 5260
program sumitrust2019b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i

    read*, n
    do i=1,n
        if (int(dble(i*1.08)) == n) then
            print'(i0)', i
            stop
        end if
    end do
    print'(a)', ':('
end program sumitrust2019b

Measured memory_bytes: 512
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.7f\n", ans); 相対誤差

int main() {
  string s;
  cin>>s;
  if (s=="Sunny") {
    cout << "Cloudy" << endl;
    return 0;
  }
  if (s=="Cloudy") {
    cout << "Rainy" << endl;
    return 0;
  }
  if (s=="Rainy") {
    cout << "Sunny" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int ll;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pow2(i) (1 << (i))
#define modi(a,b) ((a%b+b)%b)
#define uni(a,b) (((a+b)*(a+b+1)/2)+b)
const int MAXN=1e9+7;
ll int_pow(ll base, ll exp){
	ll result=1;
	while (exp){
		if (exp & 1)
		   result *= base;
		exp/=2;
		base*=base;
	}
	return result;
}
ll a[100000];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,sum=0,k=0;cin >> n;
	for (ll i=1;i<=n;i++){
		cin >> a[i];
		sum += a[i];
		k+=i;
	}
	if (sum%k != 0){cout << "NO";return 0;}
	k=sum/k;
	ll t=a[1];
	for (ll i=1;i<n;i++)a[i]=a[i+1]-a[i];
	a[n]=t-a[n];
	for (ll i=1;i<=n;i++){
		a[i]-=k;
		if (a[i]%n!=0 || a[i] > 0){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

const int mod = 1000000007;
typedef long long ll;

int dp[100010];

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    for(int i = 0; i < M; i++){
        cin >> a[i];
    }
    
    if(M >= 2){      // 0通りの場合
        for(int i = 1; i < M; i++){
            if(a[i] - a[i - 1] == 1){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    
    ll ans = 1;

    for(int i = 1; i <= N; i++){
        if(i <= 2){
            dp[i] = (dp[i - 1] + 1) % mod;
        }
        else{
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
        }
    }
    dp[0] = 1;
    int left = 0;
    for(int i = 0; i < M; i++){
        ll temp = dp[a[i] - 1 - left];
        if(temp == 0){
            ans *= 1;
        }
        else{
            ans *= temp;
            ans %= mod;
        }
        
        left = a[i] + 1;
    }
    
    ans *= dp[N - left];
    ans %= mod;
    
    cout << ans << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 3e5 + 233;
int n, m, K;
int a[N], b[N], tmp[N];
vector <int> pw[233], E, id;
inline vector <int> uni(vector <int> &a, vector <int> &b) {
  vector <int> ans(n + 1);
  for (int i = 1; i <= n; i ++)
    ans[i] = b[a[i]];
  return ans;
}

inline void getT(void) {
  pw[0] = id;
  for (int i = 1; i <= 62; i ++)
    pw[i] = uni(pw[i - 1], pw[i - 1]);
  E.resize(n + 1);
  for (int i = 1; i <= n; i ++)
    E[i] = i;
  for (int k = 62; k >= 0; k --) {
    if (K >> k & 1)
      E = uni(E, pw[k]);
  }
}

main(void) {
  read(n);
  for (int i = 1; i <= n; i ++)
    read(a[i]);
  for (int i = 1; i <= n; i ++)
    b[i] = a[i] - a[i - 1];
  read(m); read(K);
  id.resize(n + 1);
  for (int i = 1; i <= n; i ++)
    id[i] = i;
  for (int i = 1; i <= m; i ++) {
    int x; read(x); swap(id[x], id[x + 1]);
  }
  getT();
  for (int i = 1; i <= n; i ++)
    tmp[i] = b[E[i]];
  for (int i = 1; i <= n; i ++)
    tmp[i] += tmp[i - 1];
  for (int i = 1; i <= n; i ++) {
    printf("%.10Lf\n", (long double) tmp[i]);
  }
}


Measured memory_bytes: 58976
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.14159265358979323846264
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int a[200001];
int main() {
	int n;
	scanf("%d", &n);
	fup(i, 1, n, 1)
	{
		int x;
		scanf("%d", &x);
		a[x] = i;
	}
	int temp = 1, ans = 1;
	fup(i, 2, n, 1)
	{
		if (a[i] > a[i - 1])
			temp++;
		else temp = 1;
		ans = max(ans, temp);
	}
	printf("%d", n - ans);
}

Measured memory_bytes: 1024
import numpy as np
from collections import Counter

n = int(input())
a = np.array(list(map(int, input().split())))

sum = np.arange(n) + a
diff = np.arange(n) - a
sum_c = Counter(sum)
diff_c = Counter(diff)

res = 0
for k, v in sum_c.items():
    res += diff_c[k] * v
print(res)


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    A.at(0) = 1;
    for (ll i=0; i<N-1; i++) {
        cin >> A.at(i+1);
    }

    vector<ll> B(N);
    for (ll i=0; i<N; i++) {
        B.at(A.at(i)-1)++;
    }
    B.at(0)--;

    for (ll i =0; i<N; i++) {
        cout << B.at(i) <<endl;
    }
}

Measured memory_bytes: 6408
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int N;
    int ans, odd_flag;
    cin >> N;
    int A[N];
    REP(i, N){
        cin >> A[i];
    }
    ans = 0;
    odd_flag = 0;
    while(odd_flag!=1){
        REP(j, N){
            if(A[j]%2!=0){
                odd_flag = 1;
                break;
            }
            else{
                A[j] = A[j] / 2;
            }
        }
        if(odd_flag==0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set> 
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int a,b;
 cin>>a>>b;
 int c[a];
 for (int i=0;i<a;i++)
 cin>>c[i];
 sort (c,c+a);
 int d=1000000000;
 for (int i=0;i<a-b+1;i++){
 
 if (c[i+b-1]-c[i]<=d)
 d=c[i+b-1]-c[i];
  }
 cout<<d<<endl;
 system("pause");
 return 0;  }

Measured memory_bytes: 888
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


check = [False for _ in range(1000005)]

s = int(input())
cnt = 1
check[s] = True
while (1):
    s = f(s)
    cnt += 1
    if check[s]:
        print(cnt)
        exit()
    else:
        check[s] = True


Measured memory_bytes: 10904
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o D.exe D.cpp 
Execute: ./D
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

// Returns vector of primes below n 
vector<int> primes_sieve(int n) {
	vector<bool> prime (n+1, true); 
	vector<int> primes_list; 
	
	int n_sqrt = (int)(floor(sqrt( ((double)n)))); 
	
	for(int p = 2; p <= n_sqrt; p++) {
		if(prime[p]) {
			for(int i = p*2; i <= n; i += p) {
				prime[i] = false; 
			}
		}
	}
	
	for(int i = 2; i <= n; i++) {
		if(prime[i]) {
			primes_list.push_back(i); 
		}
	}
	
	return primes_list; 
}

int main() { 	
	int n; 
	int m = 10000000; 
	vector<int> num_divisors (m+1, 1);
	
	cin >> n; 
	
	vector<int> prime_list = primes_sieve(m); 
	
	long prime_j; 
	int j, test; 
	for(int i = 0; i < prime_list.size(); i++) {
		prime_j = prime_list[i]; 
		j = 1; 
		while(prime_j <= m) {			
			for(int k = prime_j; k <= m; k += prime_j) {
				num_divisors[k] /= j; 
				num_divisors[k] *= (j+1); 
			}
			if(n / prime_j >= prime_list[i]) {
				prime_j *= prime_list[i]; 
				j++; 
			}
			else 
				break; 
		}
		/*
		cout << "--------------------------------------" << endl; 
		cout << "PRIME = " << prime_list[i] << endl; 
		for(int i = 1; i <= n; i++) {
			cout << i << " " << num_divisors[i] << endl; 
		}
		cout << "--------------------------------------" << endl; 
		cin >> test; 
		*/
	}
	
	/*
	cout << "--------------------------------------" << endl; 
	for(int i = 1; i <= n; i++) {
		cout << i << " " << num_divisors[i] << endl; 
	}
	cout << "--------------------------------------" << endl; 
	*/
	
	// Calculate result
	unsigned long long int result = 0, i_prox, exp_prox; 
	for(int i = 1; i <= n; i++) {
		i_prox = (unsigned long long) i; 
		exp_prox = (unsigned long long) num_divisors[i]; 
		result += (unsigned long long)(i_prox * exp_prox); 
	}
	
	cout << result << endl; 
	
	return 0; 
} 


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

int main() {
    vector<int> a(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    int answer = 0;
    for(int i = 0; i < 5; i++){
        if(a[i] == 0){
            answer = i+1;
            break;
        }
    }
    cout << answer;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	auto result = 0;
	for (auto i = A; i <= B; ++i)
	{
		if ((i / 10000 == i % 10) && i / 1000 % 10 == i % 100 / 10)
		{
			++result;
		}
	}

	cout << result << endl;

	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var hash = new HashSet<char> { 'A','C','G','T' };
        int max = 0;
        for(int i = 0; i < S.Length; i++)
        {
            int len = 0;
            for(int j = i; j < S.Length; j++)
            {
                if (!hash.Contains(S[j]))
                {
                    break;
                }
                len++;
            }
            max = Math.Max(max, len);
        }

        Console.WriteLine(max);
    }

}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
    for(int i = 1; i <= s.size(); i++){
        for(int j = 1; j <= t.size(); j++){
            if(s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
        }
    }
    /*for(int i = 0; i <= s.size(); i++){
        cout << "\n";
        for(int j = 0; j <= t.size(); j++){
            cout << dp[i][j];
        }
    }*/
    string ans;
    int i = s.size(), j = t.size();
    while(i && j){
        if(dp[i][j] == dp[i][j - 1]) j--;
        else if(dp[i][j] == dp[i - 1][j]) i--;
        else if(dp[i][j] != dp[i - 1][j - 1]) {ans += s[i - 1]; i--; j--;}
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}


Measured memory_bytes: 35584
#include<iostream>
long dp[62][3]={1},n,b,i,j,x,y;main(){for(std::cin>>n;i<61;i++)for(b=(n>>i)&1,j=0;j<3;j++)for(x=0;x<2;x++)for(y=x;y<2;y++)(dp[i+1][(x+y+j+1-b)/2]+=dp[i][j])%=1000000007;std::cout<<dp[61][0]<<"\n";}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

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

int main(void)
{
  
    int a, b;
    char s[10];
    scanf("%d %d %s",&a,&b,s);
    
    if(strlen(s) != a+b+1 || s[a] != '-')
    {
        printf("No\n");
    }
    else
    {
        REP(i,a+b+1)
        {
            if(i != a && s[i]=='-')
            {
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
n=int(input())
s=input()
dp=[[0]*n for _ in range(n)]
ans=0
for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
        if s[i]==s[j]:
            dp[i][j]=dp[i+1][j+1]+(i+1+dp[i+1][j+1]!=j+1) if j<n-1 else 1
    ans=max(ans,max(dp[i]))
print(ans)

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  int n = s.size();
  int ans = n;
  rep(i, n-1) {
    if(s[i] != s[i+1]) {
      chmin(ans, max(i+1, n-1-i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			long ans = lcm(a, b);
			System.out.println(ans);
		}

	}

	private static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	private static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}

}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // int a, b, c, d, e;
  // cin >> a >> b >> c >> d >> e;
  vi a(5);
  int idx = 0;
  int min_mod = 9;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
    if ((a[i] % 10) != 0 && min_mod > (a[i] % 10)) {
      idx = i;
      min_mod = a[i] % 10;
    }
  }

  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (i == idx) {
      ans += a[i];
    } else {
      ans += (a[i] + 9) / 10 * 10;
    }
  }

  cout << ans << endl;

  return 0;
}


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


int main(){
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL); cout.tie(NULL);

    int n;
  	cin >> n;
  	int sum = 0;
  
  	for (int i=1; i<=n; i++) {
      int a;
      cin >> a;
      sum += a-1;
    }
  
  	cout <<sum;
}


Measured memory_bytes: 256