akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using namespace std;

int pow_mod(int a, int b, int p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

int factorial_mod(int a, int p) {
	if (!a)return 1;
	else return a * factorial_mod(a - 1, p) % p;
}

int sum_digit(int N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

int a, b;

int main(){
	scanf("%d %d", &a, &b);
	if (a <= b)printf("%d", a);
	else printf("%d", a - 1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

typedef tuple<int, int, int> iii;
typedef vector<iii> viii;

int main(int argc, char *argv[]) {
  int l;
  cin >> l;
  viii edges;
  int i = 1, j = 1;
  for (; i * 2 <= l; i *= 2);
  l -= i;
  int x = i;
   for (i /= 2; i >= 1; i /= 2, j++) {
    edges.push_back({j, j + 1, 0});
    edges.push_back({j, j + 1, i});
  }
  int n = j;
  int k = 0;
  for (int i = 20; i >= 0; i--) {
    if (l & (1 << i)) {
      x += k;
      k = 1 << i;
    }
  }
  k = 1;
  bool o = false;
  while (l > 0) {
    if (l & 1) {
      if (o) x -= k;
      else o = true;
      edges.push_back({1, j, x});
    }
    k *= 2;
    j--;
    l >>= 1;
  }
  cout << n << " " << edges.size() << endl;
  for (auto z:edges) {
    int u, v, c;
    tie(u, v, c) = z;
    cout << u << " " << v << " " << c << endl;
  }
}


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

vector<ll> fac(MAX);
vector<ll> finv(MAX);

ll power_MOD(ll a, ll b){
  ll ans = 1;
  while(b > 0){
    if(b&1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b = (b >> 1);
  }
  return ans;
}

void comb_ini(){
  fac[0] = 1; fac[1] = 1;
  finv[0] = 1; finv[1] = 1;
  for(ll i = 2; i <= MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    finv[i] = finv[i - 1] * power_MOD(i, MOD - 2) % MOD;
  }
}

ll comb_MOD(ll n, ll r){
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  if(r == 0) return 1;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main(){
  ll N; cin >> N;
  vector<ll> A(N+1);
  vector<bool> exst(N+1, 0);
  ll dpl, fst, scd;
  for(ll i = 0; i <= N; i++){
    cin >> A[i];
    if(exst[A[i]]){
      dpl = A[i];
      scd = i;
      for(ll j = 0; j < i; j++){
        if(A[j] == dpl) {fst = j; break;}
      }
    }
    exst[A[i]] = 1;
  }
  
  comb_ini();
  
  for(ll k = 1; k <= N + 1; k++){
    ll ans = (comb_MOD(N+1, k) - comb_MOD(N - (scd - fst), k-1)) % MOD;
    while(ans < 0) ans += MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3584
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int[] ary = new int[3];
		for (int i = 0; i < 3; i++) {
			ary[i] = sc.nextInt();
		}
		Arrays.sort(ary);
		int ans = ary[0] + ary[1] + ary[2] * 10;
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}
int n;
int dp[1000001][2][2];
int solvedp(int in, int ze, int ni)
{
	if (in == n)
	{
		if (ze && ni)
		{
			return 1;
		}
		return 0;
	}
	int ans = 0;
	if(dp[in][ze][ni]!=-1){
		return dp[in][ze][ni];
	}
	for (int i = 0; i <= 9; i++)
	{
		ans = ans + solvedp(in+1,((i==0)?1:ze),((i==9)?1:ni));
		ans %= mod;
	}
	return dp[in][ze][ni] = ans;
}
void solve()
{
	memset(dp, -1, sizeof(dp));

	cin >> n;
	cout << solvedp(0,0,0);
	//cout << ans << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 112828
#前から数えてく、どうなってるかは一意に決まる
import collections

n=int(input())
b=[[0,0,0]]
a=[int(i) for i in input().split()]

def my_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

for i in range(n):
    k=my_index(b[-1],a[i])
    if k==-1:
        print(0)
        break
    b.append([b[-1][j]+1 if j==k else b[-1][j] for j in range(3)])
else:
    x=1
    for i in range(n):
        x=x*b[i].count(a[i])%1000000007
    print(x)


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

using namespace std;

bool isqrt(unsigned long long x) {
	long long y = sqrt(x);
	if (y*y == x) return true;
	return false;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, d; cin >> n >> d;

	int arr[11][21];

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= d; ++j) cin >> arr[i][j];
	}


	int ans = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			unsigned long long dis2 = 0;
			for (int k = 1; k <= d; ++k) {
				dis2 += ((arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]));
			}
			if (isqrt(dis2)) {
				++ans;
			}
		}
	}

	cout << ans << "\n";
	
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
//#include "pch.h"    
using namespace std;
unordered_map<int, bool> here;
 
using ll = long long;
const int nax = 1e5 + 10;
vector<int> edges[nax];

int main() {
    
    int n;
    cin >> n;
    
    unordered_map<string, bool> here;
    
    int ans = 0;
    while(n--) {
        string s;
        cin >> s;
        if(here.count(s) == 0) {
            ++ans;
            here[s] = true;
        }
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 19928
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    int n, k;
    vector< int> L, R;
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; ++i) {
        int a; scanf("%d", &a);
        if(a < 0) L.emplace_back(-a);
        else R.emplace_back(a);
    }

    reverse(L.begin(), L.end());
    int res = 2e9;
    if(L.size() >= k) res = min(res, L[k - 1]);
    if(R.size() >= k) res = min(res, R[k - 1]);

    for(int i = 0; i < k - 1 and i < (int) L.size(); i++) {
        if(i + 1 + (int) R.size() >= k) {
            int x = k - i - 1;
            res = min(res, 2 * L[i] + R[x - 1]);
        }
    }

    for(int i = 0; i < k - 1 and i < (int) R.size(); i++) {
        if(i + 1 + (int) L.size() >= k) {
            int x = k - i - 1;
            res = min(res, 2 * R[i] + L[x - 1]);
        }
    }

    printf("%d\n", res);
}

Measured memory_bytes: 1020
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int64;

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class Solver
{
    public void Solve()
    {
        var s = rs;
        if (s[s.Length - 1] == 's') { Write(s + "es"); }
        else { Write(s + "s"); }
    }

    N Gcd(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++) { p = Gcd(p, n[i]); } return p; }
    N Gcd(N a, N b) { return (a == 0) ? b : Gcd(b % a, a); }

    N rn { get { return sc.Integer(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    void Write<T>(T t) { Console.WriteLine(t.ToString()); }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}



public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public N Integer()
    {
        N ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public double Double() { return double.Parse(Scan()); }
}


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

string v;
int main()
{
    long long n, x,y;
    cin>>v;


    x=0, y=0;
    for(int i=0; i<v.size(); i++)
      {
          if(v[i]=='0')
            x++;
          else
            y++;
      }
      x*=2;
      y*=2;
      cout<<min(x,y)<<endl;
}


Measured memory_bytes: 512
import fractions

A, B, K = map(int, input().split())
g = fractions.gcd(A, B)
if K == 1:
    print(g)
else:
    count = 1
    for i in range(g // 2, 0, -1):
        if g % i == 0:
            count += 1
        if count == K:
            print(i)
            break

Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  
  if (n[0] == n[1] && n[1] == n[2]) {
  	cout << "Yes" << endl;
  }else if ( n[1] == n[2] && n[2] == n[3]) {
  	cout << "Yes" << endl;
  }else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split("\n");
  var n= parseInt(input[0], 10);
 
   var tmp = input[1].split(" ");
     var a = [];
for (var i = 0; i < n ; i++){
  var r= parseInt(tmp[i], 10);
   a[i] = r;}
   //console.log(a);
 var ct = 0;
  var p = 0;
 for (var i = 0;i < n ;i ++){ if( a[i] >= a[i+1]){ct = ct + 1;
                                                 // console.log(i,ct);
                                                  }
                                         else if (p < ct){ var p =ct;
                                               var ct = 0;}else{var ct = 0;}
                               }
                   console.log(p);
 
 

 

}
 
  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 27984
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a , b;
	cin >> a >> b;
	if(a <= 0 && b >= 0)
	{
		cout << "Zero";
		return 0;
	}
	if(b < 0)
	{
		if((b - a + 1) % 2 == 0)
		{
			cout << "Positive";
		}
		else
		{
			cout << "Negative";
		}
	}
	else
	{
		cout << "Positive";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000000;
bool is_prime[SIZE];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin());

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

int calc(int p, int c, const vector<string> &s){
	int tmp = 0;
	while(tmp < c) tmp += s[p++].size();
	if(tmp == c) return p;
	return -1;
}

int main(){
	while(1){
		int n = in.nextInt();
		if(n == 0) break;
		vector<string> s(n);
		rep(i, n) s[i] = in.next();
		vi d(n + 1);
		rep(i, n) d[i + 1] = d[i] + s[i].size();
		int a[] = {5, 7, 5, 7, 7};
		rep(i, n){
			int p = i;
			for(int j = 0; j < 5; j++){
				p = calc(p, a[j], s);
				if(p < 0) break;
			}
			if(p >= 0){
				cout<<i + 1<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1232
r, c = map(int, input().split())
list1 = [list(map(int, input().split())) for i in range(r)]
for i in range(r):
    list1[i].append(sum(list1[i]))
list2 = []
for i in range(c + 1):
    sum1 = 0
    for j in range(r):
        sum1 += list1[j][i]
    list2.append(sum1)
for i in range(r):
    list1[i] = map(str, list1[i])
    print(' '.join(list1[i]))
list2 = map(str, list2)
print(' '.join(list2))


Measured memory_bytes: 5676
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
    public static void main(String[] args)throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br=new BufferedReader(isr);
	String str = br.readLine();
	while(str!=null){
	    String[] s =str.split(" ");
	    int a = Integer.parseInt(s[0]);
	    int b = Integer.parseInt(s[1]);
	    int c = Integer.parseInt(s[2]);
	    int d = Integer.parseInt(s[3]);
	    int e = Integer.parseInt(s[4]);
	    int f = Integer.parseInt(s[5]);
	    BigDecimal x =new BigDecimal((double) (c*e-b*f)/(a*e-b*d));
	    BigDecimal y = new BigDecimal((double)(a*f-c*d)/(a*e-b*d));
	    x=x.setScale(3,BigDecimal.ROUND_HALF_UP);
	    y=y.setScale(3,BigDecimal.ROUND_HALF_UP);
	      System.out.println(x+" "+y);
	    str = br.readLine();
	}
    }
}

Measured memory_bytes: 16972
#include <bits/stdc++.h>
#include <atcoder/all>
//g++ main.cpp -std=c++14

using namespace std;
using namespace atcoder;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}
const ll MAX = MOD;

void solve(){
  int T; cin>>T;
  REP(i,T){
    ll N,M,A,B; cin>>N>>M>>A>>B;
    cout << floor_sum(N,M,A,B) << "\n";
  }
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3600
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()
ans = D(int)
for _ in range(n):
  s = S()
  ans[s] += 1

for x in ['AC', 'WA', 'TLE', 'RE']:
  print('{} x {}'.format(x, ans[x]))

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


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

    string s1,s2;
    int mn=INT_MAX,curr=0;
    cin>>s1>>s2;
    for(int i=0;i<=s1.length()-s2.length();i++){
        curr=0;
        for(int j=i;j<i+s2.length();j++){
            if(s2[j-i]!=s1[j])
                curr++;
            //cout<<s1[j];
        }
        //cout<<endl;
        mn=min(mn,curr);
    }
    cout<<mn<<endl;
}



Measured memory_bytes: 3648
# D - Even Relation

# 木なのでノードAB間の辺を辿ればそれがAB間の最短経路となる
# 全ての｢辺｣についてループする

from collections import deque

N = int(input())

edge = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])

color = [0] + [-1]*(N-1)
d = deque([0])

while d:
    current_point = d.pop()
    for current_edge in edge[current_point]:
        if color[current_edge[0]] == -1:
            color[current_edge[0]] = (color[current_point] + current_edge[1]) % 2
            d.append(current_edge[0])

for idx in range(N):
    print(color[idx])

Measured memory_bytes: 45316
fun main(args:Array<String>) {

    val (h,n) = readLine()!!.split(" ").map { it.toInt() }
    val item = Array(n){0 to 0}

    for(i in 0 until n) {
        val (damage, point) = readLine()!!.split(" ").map { it.toInt() }
        item[i] = damage to point
    }
    val inf = 100000000
    // 10000000
    val dp =Array(h+1){inf}
    dp[0] = 0
    for(i in 0 until n) {
        val (damage, point) = item[i]
        for(j in 1..h) {
            val diff = j - damage
            val prev = if(diff < 0) 0 else diff 
            if(dp[j] > dp[prev]+point) {
                dp[j] = dp[prev]+point
            }
        }
    }
    println(dp[h])
}

Measured memory_bytes: 40752
open Printf
open Str

let inputs string =
	let nums = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") string)) in
	let hms nums =
		let cnt = ref 0 in
		for i=nums.(0) to nums.(1) do	
			if 0 = (nums.(2) mod i) then cnt := (!cnt+1)
		done;
		printf "%d\n" !cnt in
	hms nums;;


let s = read_line() in
	inputs s;;

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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  int n;
  cin >> n;
  int a[1000000];
  int bai4=0,bai2=0,kisuu=0;
  FOR(i,n){
    cin >> a[i];
    if(a[i]%4==0){
      bai4++;
    }else if(a[i]%2==0){
      bai2++;
    }else{
      kisuu++;
    }
  }
  if(bai2==0)bai2++;
  if(bai2-1+bai4*2>=n-1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (2e6 + 5)
#define mod (int) 1000000007

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

lli p25[limit],p26[limit],fac[limit];

lli power(lli base,lli power)
{
    base %= mod;
    lli ans = 1;

    while(power > 0)
    {
        if (power%2)
        {
            ans *= base;
            ans %= mod;
        }

        base *= base;
        base %= mod;
        power /= 2;
    }

    return ans;
}

int main()
{
    lli k;
    cin >> k;

    string s;
    cin >> s;

    p25[0] = p26[0] = fac[0] = 1;

    lli l = s.length();

    for (int i = 1; i <= l+k; ++i)
    {
        p25[i] = (p25[i-1]*25)%mod;
        p26[i] = (p26[i-1]*26)%mod;
        fac[i] = (fac[i-1]*i)%mod;
    }

    lli ans = 0,temp;
    for (int i = 0; i <= k; ++i)
    {
        temp = fac[l+k-1-i];
        temp *= power( fac[l-1]*fac[k-i],mod-2 );
        temp %= mod;
        temp *= p25[k-i];
        temp %= mod;
        temp *= p26[i];
        temp %= mod;

        ans += temp;
        ans %= mod; 
    }
    
    cout << ans;
    return 0;
}













Measured memory_bytes: 51128
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a = k()
print(int(a+a**2+a**3))




Measured memory_bytes: 10500
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;

int doubling(int n, ll k, vector<int> &a){
	
	int m = log2(k);
	vector<vector<int>> d(m+1,vector<int>(n,-1));
	d.at(0) = a;
	for(int i=1; i<=m; i++){
		for(int j=0; j<n; j++){
			d.at(i).at(j) = d.at(i-1).at(d.at(i-1).at(j));
		}
	}
	int now{},cnt{};
	while(k){
		if(k&1){
			now = d.at(cnt).at(now);
		}
		k>>=1;
		cnt++;
	}
	return now;
}

int main(){
	
	ll n,k; cin>>n>>k;
	vector a(n,0);
	for(auto &i:a) {
		cin>>i;
		--i;
	}
	cout << doubling(n,k,a)+1 << endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, W;
  IN(H,W);

  REP(i,W+2){
    printf("#");
  }
  printf("\n");

  REP(i,H){
    string S;
    IN(S);
    printf("#");
    REP(j,W){
      printf("%c", S[j]);
    }
    printf("#\n");
  }

  REP(i,W+2){
    printf("#");
  }
  printf("\n");



  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;

int main(){
    int N, H, W;
    cin >> N >> H >> W;
    int ans = (N-H+1)*(N-W+1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char>> s(h, vector<char>(w));
	rep(i, h)rep(j, w) cin >> s[i][j];
	vector<vector<int>> ans(h, vector<int>(w));
	vector<bool> jud(w, false);
	rep(i, w)rep(j, h) if (s[j][i] == '#') jud[i] = true;
	int cnt = 1;
	rep(i, w) {
		int res = 0;
		if (!jud[i]) continue;
		rep(j, h) {
			if (s[j][i] == '#') {
				res++;
				if (res != 1) cnt++;
			}
			ans[j][i] = cnt;
		}
		cnt++;
	}
	/*rep(i, w) {
		rep(j, h) {
			if (ans[j][i] == 0) {
				if (i - 1 >= 0) {
					ans[j][i] = ans[j][i - 1];
				}
			}
		}
		for (int j = h - 1; j >= 0; --j) {
			if (ans[j][i] == 0) {
				if (i + 1 < w) {
					ans[j][i] = ans[j][i + 1];
				}
			}
		}
	}*/
	rep(i, h) {
		rep(j, w) {
			if (ans[i][j] == 0) {
				if (j - 1 >= 0) {
					ans[i][j] = ans[i][j - 1];
				}
			}
		}
		for (int j = w - 1; j >= 0; --j) {
			if (ans[i][j] == 0) {
				if (j + 1 < w) {
					ans[i][j] = ans[i][j + 1];
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) cout << ans[i][j] << (j == w - 1 ? "\n" : " ");
	}
	
	return 0;
}

Measured memory_bytes: 1280
N = int(input())
ab = [list(map(int,input().split())) for _ in range(N)]
cd = [list(map(int,input().split())) for _ in range(N)]

ab.sort(key = lambda x:x[0])
cd.sort(key = lambda x:x[0])
cnt = 0
for i in range(N):
    x = cd[i][0]
    tmplist = []
    for j in range(len(ab)):
        if ab[j][0] >= x:
            break
        tmplist += [ab[j]]
    tmplist.sort(key = lambda x:x[1],reverse = True)
    for j in range(len(tmplist)):
        if cd[i][1] > tmplist[j][1]:
            cnt += 1
            ab.remove(tmplist[j])
            break
        
print(cnt)
    
    
        

Measured memory_bytes: 3064
#include <iostream>
#include <stdint.h>

using namespace std;

int main() {
  int N, A;
  cin >> N >> A;

  while (N >= 0) {
    N -= 500;
  }

  if (N + 500 - A <= 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, count=0;
  cin >> A >> B;

  for(int i = A; i <= B; i++){
    int s = i % 10;
    int t = i / 10000 % 10;
    int u = i / 10 % 10;
    int v = i / 1000 % 10;

    if(s == t && u == v) count++;
  }

  cout << count << endl;

  return 0;
}

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

using namespace std;

int main(void)
{
    long long N;
    cin >> N;
    vector<char> s;
    int k = 0;
    for (int i = 0; i < N; i++) {
        char c;
        cin >> c;
        if (i == 0) {
            s.push_back(c);
            continue;
        }
        if (s.back() == c) {
            continue;
        } else {
            s.push_back(c);
        }
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t;
		while ((t = in.nextInt()) > 0) {
			int n = in.nextInt();
			int time = 0;
			while (n-- > 0) {
				time -= in.nextInt();
				time += in.nextInt();
			}
			if (time >= t) {
				System.out.println("OK");
			} else {
				System.out.println(t - time);
			}
		}
	}
}

Measured memory_bytes: 23556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if((a+b) % 2 == 0){
	  cout << (a + b) / 2 << endl;
  }else{
	  cout << (a + b) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int H,W,i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(j=0;j<W;j++){
			printf("#");
		}
		printf("\n");
		for(i=0;i<H-2;i++){
			printf("#");
			for(j=0;j<W-2;j++){
				printf(".");
			}
			printf("#\n");
		}
		for(j=0;j<W;j++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  regex ABC(R"(ABC)"),A(R"(A)"),B(R"(B)"),C(R"(C)");
  Int flg=0;
  function<void(string)> dfs=
    [&](string s){
      if(s=="ABC") flg=1;
      if(flg) return;
      string sa=regex_replace(s,ABC,"A");
      if(sa.size()<s.size()&&regex_replace(sa,A,"ABC")==s) dfs(sa);
      string sb=regex_replace(s,ABC,"B");
      if(sb.size()<s.size()&&regex_replace(sb,B,"ABC")==s) dfs(sb);
      string sc=regex_replace(s,ABC,"C");
      if(sc.size()<s.size()&&regex_replace(sc,C,"ABC")==s) dfs(sc);
    };
  string t;
  cin>>t;
  dfs(t);
  cout<<(flg?"Yes":"No")<<endl;
  return 0;
}



Measured memory_bytes: 42172
//Number 1137

#include <stdio.h>
#include <string.h>
#define MAX 10

int mcxi_to_i(char *array);
void print_by_mcxi(int sum);

int main(void)
{
  int n, i, answer = 0;
  
  scanf("%d", &n);

  for(i=0; i<n; i++)
    {
      char num1[MAX] = {0};
      char num2[MAX] = {0};

      scanf("%s %s", num1, num2);
      
      answer = mcxi_to_i(num1) + mcxi_to_i(num2);

      print_by_mcxi(answer);
    }

  return 0;
}

int mcxi_to_i(char *array)
{
  int j, integer = 0;

  for(j=0; array[j] != '\0'; j++)
    {
      if(array[j] >= '2' && array[j] <= '9')
	{
	  j++;
	  switch(array[j])
	    {
	    case 'm':
	      integer += (array[j-1]-'0')*1000;
	      break;
	    case 'c':
	      integer += (array[j-1]-'0')*100;
	      break;
	    case 'x':
	      integer += (array[j-1]-'0')*10;
	      break;
	    case 'i':
	      integer += (array[j-1]-'0')*1;
	      break;
	    default:
	      break;
	    }
	}
      else
	{
	  switch(array[j])
	    {
	    case 'm':
	      integer += 1000;
	      break;
	    case 'c':
	      integer += 100;
	      break;
	    case 'x':
	      integer += 10;
	      break;
	    case 'i':
	      integer += 1;
	      break;
	    default:
	      break;
	    }
	}
    } 
  return integer;
}

void print_by_mcxi(int sum)
{
  int m = 0, c = 0, x = 0, i = 0;

  m = sum / 1000;
  c = (sum - 1000 * m) / 100;
  x = (sum - 1000 * m - 100 * c) / 10;
  i = (sum - 1000 * m - 100 * c - 10 * x);

 
  if(m==1)
    printf("m");
  else if(m>1)
    printf("%dm", m);
  
  if(c==1)
    printf("c");
  else if(c>1)
    printf("%dc", c);
  
  if(x==1)
    printf("x");
  else if(x>1)
    printf("%dx", x);
  
  if(i==1)
    printf("i");
  else if(i>1)
    printf("%di", i);

  printf("\n");
    
}

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

int main(){
  int graph[101][101];
  int vol_size;
  int vol, deg, v;
  cin >> vol_size;
  // init
  rep(i,vol_size + 1){
    rep(j,vol_size + 1){
      graph[i][j] = 0;
    }
  }

  rep(i,vol_size){
    cin >> vol >> deg;
      rep(j,deg){
        cin >> v;
        graph[vol][v] = 1;
      } 
  }

  for(int i = 1; i <= vol_size; i++){
    for(int j = 1; j<= vol_size; j++){
      if(j > 1) cout << " ";
      cout << graph[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3128
n, l = gets.split.map(&:to_i)
flavors = []
n.times do |i|
  flavors << l + i
end

res =
  if l.negative?
    n <= l.abs ? flavors.inject(:+) + flavors.max.abs : flavors.inject(:+)
  else
    flavors[1..-1].inject(:+)
  end

puts res


Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a, b, c;
    cin >> a >> b >> c;
    
    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [input() for i in range(3)]

count = 0
for k in range(n):
    this_set_len = len({a[0][k], a[1][k], a[2][k]})
    if (this_set_len == 2):
        count = count + 1
    elif (this_set_len == 3):
        count = count + 2

print(count)

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

int main(){
	string S;
	int K;
	cin >> S >> K;
	
	int len=S.size();
	int dp[len+1][2][K+1];
	for(int i=0;i<len+1;i++)for(int j=0;j<K+1;j++)dp[i][0][j]=0;
	for(int i=0;i<len+1;i++)for(int j=0;j<K+1;j++)dp[i][1][j]=0;
	
	dp[0][0][0]=1;
	
	for(int i=0;i<len;i++){
		for(int smaller=0;smaller<2;smaller++){
			for(int j=0;j<K+1;j++){
				for(int x=0;x<=(smaller ? 9:(int)(S[i]-'0'));x++){
					if(x>0 && j<K)dp[i+1][smaller || (x<(int)(S[i]-'0'))][j+1]+=dp[i][smaller][j];
					if(x==0)dp[i+1][smaller || (x<(int)(S[i]-'0'))][j]+=dp[i][smaller][j];
				}
			}
		}
	}
	cout << dp[len][0][K]+dp[len][1][K] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int h = 2, w = 3;
	vector<string> grid(h);
	rep(i, h) cin >> grid[i];

	rep(i, h) rep(j, w){
		if(grid[i][j] != grid[h - 1 - i][w - 1 - j]){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}


Measured memory_bytes: 384
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
ans = 0
if N%2==0:
    B1 = A[:N//2]
    B2 = A[N//2:]
    ans = 2*(sum(B2)-sum(B1)) + B1[-1] - B2[0]
else:
    B1 = A[:N//2]
    B2 = A[N//2:]
    p = 2*(sum(B2)-sum(B1)) - B2[0] - B2[1]

    C1 = A[:N//2+1]
    C2 = A[N//2+1:]
    q = 2*(sum(C2)-sum(C1)) + C1[-1] + C1[-2]
    ans = max(p, q)

print(ans)

Measured memory_bytes: 8532
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

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

	for (int i = 0; test[i]; i++) {
		test[i] = (test[i] - 'A' + n) % 26 + 'A';
	}

	printf("%s", test.c_str());

	return 0;
}



Measured memory_bytes: 384
#encoding:utf-8 No.0055 2014.10.8
while gets
  num = $_.chomp.to_f
  if num == 0.0
    break
  end

  sum = num
  i = 1

  while i < 10
    i += 1
    if i%2 == 0
      num = num*2
      sum += num
    else
      num = num/3
      sum += num
    end
  end

  printf("%.8f\n",sum)
end

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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0,rep,cnt,sad;
char c;
string s;
vector <ll> V;
ll L[10000010];

int main()
{
    cin >> n;

    for (int i=1;i<=n;i++){
        x=i;
        while (x<=n){
            L[x]++;
            x+=i;
        }
    }

    for (int i=1;i<=n;i++){
        sol+=L[i]*i;
    }
    cout << sol;
}



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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b)
{
    if (a < b)
    {
        a = b;
    }
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b)
{
    if (a > b)
    {
        a = b;
    }
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    int N;
    cin >> N;
    uint64_t ans = 0;

    for (int i = 1; i <= N; ++i)
    {
        uint64_t div = N / i;
        ans += (1 + div) * div * i / 2;
    }
    cout << ans << endl;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
            string[] N = Input.ScanStrArray();
          int a = int.Parse(N[0]);
          int b = int.Parse(N[2]);
          if(N[1] == "+")
          Console.WriteLine(a+b);
          else
            Console.WriteLine(a-b);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{
    string a;
    cin>>a;
    if(a[2]==a[3]&&a[4]==a[5])printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int H, W; cin >> H >> W;
  
  vector<string> a(H);
  rep(i, H) cin >> a[i];
  
  vector<vector<bool>> t(H, vector<bool>(W, true));
  
  rep(i, H) {
    bool k = false;
    rep(j, W) if(a[i][j] == '#') k = true;
    if(!k) rep(j, W) t[i][j] = false;
  }
  rep(j, W) {
    bool k = false;
    rep(i, H) if(a[i][j] == '#') k = true;
    if(!k) rep(i, H) t[i][j] = false;
  }
  
  rep(i, H) {
    bool k = false;
    rep(j, W) {
      if(t[i][j]) {
        cout << a[i][j];
        k = true;
      }
    }
    if(k) cout << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int take = min(a, k);
	int ans = 0;
	k -= take;
	ans += take * 1;
	take = min(b, k);
	k -= take;
	ans += take * 0;
	ans += k * -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3652
class SegmentTree:
    def __init__(self, n, segment_func, identity_element):
        self.n = n
        self.num = 1 << (self.n - 1).bit_length()
        self.segment_func = segment_func
        self.identity_element = identity_element
        self.segment_tree = [self.identity_element] * (2 * self.num)

    def initialize(self, val_arr):
        for i in range(self.n):
            self.segment_tree[self.num + i] = val_arr[i]
        for i in range(self.num - 1, 0, -1):
            self.segment_tree[i] = self.segment_func(self.segment_tree[2 * i], self.segment_tree[2 * i + 1])

    def update(self, idx, val):
        idx += self.num
        self.segment_tree[idx] = val
        while idx > 1:
            self.segment_tree[idx >> 1] = self.segment_func(self.segment_tree[idx], self.segment_tree[idx ^ 1])
            idx >>= 1

    def query(self, left, right):
        res = self.identity_element
        left += self.num
        right += self.num
        while left < right:
            if left & 1:
                res = self.segment_func(res, self.segment_tree[left])
                left += 1
            if right & 1:
                res = self.segment_func(res, self.segment_tree[right - 1])
            left >>= 1
            right >>= 1
        return res

    def bisect_left(self, left, right, target):
        left += self.num
        right += self.num
        left_min = -1
        right_min = -1
        while left < right:
            if left & 1:
                if self.segment_tree[left] >= target and left_min == -1:
                    left_min = left
                left += 1
            if right & 1:
                if self.segment_tree[right - 1] >= target:
                    right_min = right - 1
            left >>= 1
            right >>= 1
        if left_min != -1 or right_min != -1:
            res = left_min if left_min != -1 else right_min
            while res < self.num:
                if self.segment_tree[2 * res] >= target:
                    res *= 2
                else:
                    res *= 2
                    res += 1
            return res - self.num
        else:
            return self.n


def main():
    n, k = map(int, input().split())
    a = [int(input()) for _ in range(n)]
    max_val = 3 * 10 ** 5
    st = SegmentTree(max_val + 1, max, 0)
    for aa in a:
        st.update(aa, st.query(max(0, aa - k), min(max_val, aa + k) + 1) + 1)
    print(st.query(1, max_val + 1))


if __name__ == '__main__':
    main()


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

int main(){
  ll n,sum=0;
  cin >> n;
  for(ll i=1;i<n+1;i++){
    if(i%3!=0 && i%5!=0 && i%15!=0){
        sum+=i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3640