akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define MAXN 110
#define MAXW 10010
int N, W;
int v[MAXN], w[MAXN];
long long dp[MAXN][MAXW];
int main(void) {
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }
    for (int i = 0; i < W; i++) {
        dp[0][i] = 0;
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

vector<vector<int>> bfs2(vector<vector<char>> &s, int st_h, int st_w)
{
  int h = s.size();
  int w = s[0].size();

  queue<pair<int, int>> que;
  que.push(make_pair(st_h, st_w));

  vector<vector<int>> memo(h, vector<int>(w, -1));
  memo[st_h][st_w] = 0;

  pair<int, int> dt[4] = {
                          make_pair(-1, 0),
                          make_pair(0, -1),
                          make_pair(1, 0),
                          make_pair(0, 1)
  };

  while (!que.empty()) {
    pair<int, int> pt = que.front();
    que.pop();

    int score = memo[pt.first][pt.second];
    rep (i, 0, 4) {
      int new_h = pt.first + dt[i].first;
      int new_w = pt.second + dt[i].second;
      if (new_h < 0 || new_h >= s.size()
          || new_w < 0 || new_w >= s[0].size())
        continue;

      if (s[new_h][new_w] == '#' || memo[new_h][new_w] != -1) {
        continue;
      } else {
        que.push(make_pair(new_h, new_w));
        memo[new_h][new_w] = score + 1;
      }
    }
  }

  return memo;
}

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

  int h, w;
  cin >> h >> w;

  vector<vector<char>> s(h, vector<char>(w));
  rep (i, 0, h)
    rep (j, 0, w)
    cin >> s[i][j];

  int res = 0;
  rep (i, 0, h) {
    rep (j, 0, w) {
      vector<vector<int>> memo = bfs2(s, i, j);
      rep (k, 0, h) {
        rep (l, 0, w) {
          if (s[i][j] == '.' && memo[k][l] != -1)
            res = max(res, memo[k][l]);
        }
      }
    }
  }
  cout << res << endl;

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int used[2][100005];
int t[100005][2];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	bool flag=true;
	int s=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		a--,b--;
		if(used[0][a] || used[1][b])flag=false;
		used[0][a]=i+1,used[1][b]=i+1;
		t[i][0]=a,t[i][1]=b;
	}
	if(!flag){
		cout<<-1<<endl;
		return 0;
	}
	for(i=0;i<n;i++){
		if(used[0][i]==0)continue;
		if(used[0][i]==used[1][i])continue;
		s++;
		a=used[0][i]-1;
		b=used[1][i]-1;
		t[b][1]=t[a][1],t[a][1]=i;
		
		used[1][i]=a+1,used[1
		][t[b][1]]=b+1;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 4612
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
ll sum(ll n){return n*(n+1)/2;} 

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,sum=0,ans=0,Max=0, Min=3e9+1;
  string s,t;
  cin >> n;
  VL a(n),b(n);
  rep(i,n) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(ALL(b));
  rep(i,n){
    if(a[i] > b[n/2-1])
      pri(b[n/2-1]);
    else
      pri(b[n/2]);
  }
  return 0;
}

Measured memory_bytes: 6380
def main():
    n, m = map(int, input().split())
    sukiList = [x + 1 for x in range(m)]
    for i in range(n):
        k, *a = list(map(int, input().split()))
        sukiList = set(sukiList) & set(a)
    print(len(sukiList))


if __name__ == '__main__':
    main()


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

struct Node {
	int d, y, x;
};

int N, M;
int sy, sx, ey, ex;
string s[1010];
deque<Node> dq;
int dist[1010][1010];
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main()
{
	memset(dist, 0x3f, sizeof(dist));
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M >> sy >> sx >> ey >> ex;
	sy--; sx--; ey--; ex--; // 0-based
	for(int i=0; i<N; i++)
		cin >> s[i];
	
	dq.push_back({0, sy, sx});
	while(!dq.empty())
	{
		int d = dq.front().d, y = dq.front().y, x = dq.front().x;
		dq.pop_front();

		if (dist[y][x] < d) continue;

		for(int i=0; i<4; i++)
		{
			int ny = y + dir[i][0], nx = x + dir[i][1], nd = d;
			if (ny < 0 || nx < 0 || ny >= N || nx >= M) continue;
			if (s[ny][nx] == '#') continue;
			if (dist[ny][nx] <= nd) continue;
			
			dq.push_front({nd, ny, nx});
			dist[ny][nx] = nd;
		}

		for(int i=-2; i<=2; i++)
			for(int j=-2; j<=2; j++)
			{
				int ny = y+i, nx = x+j, nd=d+1;

				if (ny < 0 || nx < 0 || ny >= N || nx >= M) continue;
				if (s[ny][nx] == '#') continue;
				if (dist[ny][nx] <= nd) continue;
				
				dq.push_back({nd, ny, nx});
				dist[ny][nx] = nd;
			}
	}
	int res = dist[ey][ex];
	if (res == 0x3f3f3f3f) res = -1;
	cout << res;
	return 0;
}

Measured memory_bytes: 8788
from fractions import gcd

a,b,c,d = map(int,input().split())
lcm = (c*d)//gcd(c,d)
ans = 0
a -= 1

# 全体-（cで可+dで可-両方可）
ans += b-((b//c)+(b//d)-(b//lcm))
ans -= a-((a//c)+(a//d)-(a//lcm))

print(ans)

Measured memory_bytes: 5048
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static long calc(long b, long[] array) {
		long sum = 0;
		for(int i = 0; i < array.length; i++) {
			sum += Math.abs(array[i] - (b + (i + 1)));
		}
		
		return sum;

	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long[] array = new long[N];
			long[] values = new long[N];
			for(int i = 0; i < N; i++){
				array[i] = sc.nextLong();
				values[i] = array[i] - (i + 1);
			}
			
			Arrays.sort(values);
			//System.out.println(Arrays.toString(values));
			
			if(N == 1) {
				System.out.println(calc(values[N / 2], array));
			}else {
				System.out.println(Math.min(calc(values[N / 2], array), calc(values[N / 2 + 1], array)));
			}
			
			
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 53832
H,N = [int(zz) for zz in input().split()]
li = [[int(zz) for zz in input().split()] for _ in range(N)]

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

for j in range(1,H+1):
    if j <= li[0][0]:
        dp[0][j] = li[0][1]
    else:
        dp[0][j] = dp[0][j-li[0][0]]+li[0][1]

for i in range(1,N):
    for j in range(1,H+1):
        if j <= li[i][0]:
            dp[i][j] = min(li[i][1],dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j-li[i][0]]+li[i][1],dp[i-1][j])

print(dp[-1][-1])


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

using namespace std;

#define ll long long
#define endl '\n'

bool compare(const pair<string, int> &p1, const pair<string, int> &p2) {
    if (p1.second > p2.second) return true;
    else if (p1.second == p2.second) {
        return !(p1.first > p2.first);
    } else return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        m[s]++;
    }
    int max = 0;
    for (auto &x : m) {
        if (x.second >= max) max = x.second;
    }
    for (auto &it : m) {
        if (it.second == max) cout << it.first << endl;
    }
    return 0;
}

Measured memory_bytes: 23808
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		int oddCount =0;
		int evalCount =0;

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(a%2==0){
				oddCount++;
			}else{
				evalCount++;
			}
			list.add(a);
		}

		if(evalCount==0){
			System.out.println("YES");
		}else if (evalCount%2==0){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}



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

#define MAX 10000000

long long divisors[MAX + 1] = { 0, };
int n;
long long sum = 0;

int main() {
	cin >> n;

	memset(divisors, 0, sizeof(divisors));

	for (int i = 1; i <= MAX; i++) {
		for (int j = 1; j <= MAX/i; j++) {
			divisors[i*j]++;
		}
	}
	
	for (int i = 1; i <= n; i++) {
		sum += divisors[i]*i;
	}

	cout << sum;
}


Measured memory_bytes: 81752
import math

def cmb(n, r, mod):
    r = min(r, n-r)

    a = 1
    b = 1
    for i in range(r):
        a = (a * (n-i)) % mod
        b = (b * (i+1)) % mod
    
    return a * pow(b, mod-2, mod) % mod

X, Y = [int(i) for i in input().split()]
mod = 10**9+7 
x_tmp = 2*X - Y
y_tmp = 2*Y - X

if x_tmp < 0 or y_tmp < 0:
    ans = 0
elif x_tmp % 3 != 0 or y_tmp % 3 != 0:
    ans = 0
else:
    x = x_tmp // 3
    y = y_tmp // 3
    ans = cmb(x + y, y, mod)

print(ans)

Measured memory_bytes: 3064
# include "iostream"
# include "cstdio"
# include "cstring"

using namespace std;

int main(){
	int size,n; 
	char s[10000],ans[10000];
	scanf("%s%d",s,&n);
	size=strlen(s);
	register int i,j;
	for(i=0,j=0;i<=size;i+=n,j++){
		ans[j]=s[i];
	}
	ans[j]='\0';
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            using namespace std;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef  long long  int ll;
            const int N = ( 2e6 + 5 );
            const int mod = 1e9+7;
            ll n ,a[N] ,k;

    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt ; pt %= mod;
        if(n&1)
            pt *= a , pt %= mod;
        return pt;
    }

    ///  6 ^ (number of prime factors in n)


ll binpower(ll base, ll e, ll mod) {
    ll result = 1;
    base %= mod;
    while (e) {
        if (e & 1)
            result = (ll)result * base % mod;
        base = (ll)base * base % mod;
        e >>= 1;
    }
    return result;
}

bool check_composite(ll n, ll a, ll d, int s) {
    ll x = binpower(a, d, n);
    if (x == 1 || x == n - 1)
        return false;
    for (int r = 1; r < s; r++) {
        x = (ll)x * x % n;
        if (x == n - 1)
            return false;
    }
    return true;
};

    bool MillerRabin(ll n) {
    if (n < 2)
        return false;

    int r = 0;
    ll d = n - 1;
    while ((d & 1) == 0) {
        d >>= 1;
        r++;
    }

    for (int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}) {
        if (n == a)
            return true;
        if (check_composite(n, a, d, r))
            return false;
    }
    return true;
    }

    int main()
    {
         IOS;
      //     freopen("a_example (2).txt","r",stdin);
      //     freopen("c.txt","w",stdout);

        int ts =1;
      //  cin>>ts;
        while(ts--)
        {
            cin >> n >> k;
            if( n < k)
                cout << min(n, k- n) << endl;
            else
            {
                cout << min (n -((n-k)/k)*k -k , k  - (n -((n-k)/k)*k -k) ) << endl;
            }
        }
    }


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

map<char, bool> mp;
string a;
int ans;
int main(void) {
	cin >> a;
	FOR(i, 0, a.size()) {
		mp[a[i]]=true;
	}
	if (a.size() != 26) {
		FOR(i, 'a', 'z' + 1) {
			if (mp[i] == false) {
				ct(a + char(i));
				return 0;
			}
		}
	}
	else {
		for (int i = 24; i >= 0; i--) {
			char mi = a[i], cur = 'z'+1;
			FOR(k, i + 1, 27) {
				if (mi<a[k] && cur>a[k])cur = a[k];
			}
			if (cur == 'z' + 1)continue;
			swap(a[i], cur);
			ct(a.substr(0, i+1));
			return 0;
		}
	}
	ct(-1);
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

ll msd(ll n)
{
    while(n >= 10) n /= 10;
    return n;
}

int main()
{
    ll N;
    cin >> N;

    mat C(10, vec(10, 0));
    REP(i,1,N+1) ++C[msd(i)][i%10];
    
    ll c = 0;
    REP(i,0,10) {
        REP(j,0,10) c += C[i][j] * C[j][i];
    }
    PR(c);

    return 0;
}

/*

C[i][j] (1 <= i, j <= 9)

A = i*******j
B = j****i

*/

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

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

    long long int n, a, b;
    cin >> n >> a >> b;

    if ((a + b) == n) {
        cout << a << endl;
    } else if ((a + b) > n) {
        if (a > n) {
            cout << n << endl;
        } else {
            cout << a << endl;
        }
    } else {
        // a + b < n
        long long div = n / (a + b);
        long long mod = n % (a + b);
        if (mod == 0) {
            cout << a * div << endl;
        } else {
            if (a >= mod) {
                cout << a * div + mod << endl;
            } else {
                cout << a * div + a << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
using ll = long long;

#define V_MAX 100000
#define INF 1L<<61

int main()
{
    int N,W;
    cin >> N >> W;
    
    ll dp[V_MAX+1];
    fill(dp,dp+V_MAX+1,INF);
    dp[0] = 0;
    
    ll w,v;
    for (int i = 0;i < N;i++){
        cin >> w >> v;
        for (int j = V_MAX;j >= v;j--){
            dp[j] = min(dp[j],dp[j-v]+w);
        }
    }
    ll ans = 0;
    
    for (int i = 0;i <= V_MAX;i++){
        if (dp[i] <= W){
            ans = max(ans,(ll) i);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
                #include <set>
                #include<ext/pb_ds/assoc_container.hpp>
				#include<ext/pb_ds/tree_policy.hpp>
				using namespace __gnu_pbds;
				#define ordered_set  tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
                using namespace std;
                #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
                #define pb push_back
                #define ff first
                #define ss second
                #define sz size()
                #define mp make_pair
                #define p(x) cout<< x << " ";
                #define pe(x) cout<< x << endl ;
                #define int long long
                #define double long double
                #define bp __builtin_popcountll
                #define FOR(i,a,b) for(int i=a;i<b;i++)
                #define ROR(i,a,b) for(int i=a;i>=b;i--)
                const int M=1000000007;
                const int N=1e6+1;
                int n,w;
                int price[105],weight[105],dp[105][100005];
                int power(int x,int n)
                {
                	if(n==0) return 1;
                	if(n%2==0)
                	return (power((x*x)%M,n/2))%M;
                	return ((x%M)*power((x*x)%M,n/2))%M;
                }
                int solve(int idx,int we)
                {
                	if(we>w) return -1e10;
                	if(idx==0)
                	{
                		if(we<=w) return 0;
                		return -1e10;
                	}
                	int &ans=dp[idx][we];
                	if(ans!=-1) return ans;
                	ans=0;
                	ans=max(price[idx]+solve(idx-1,we+weight[idx]),solve(idx-1,we));
                	return ans;
                	
                }
                int32_t main()
                {
                	cin>>n>>w;
                	memset(dp,-1,sizeof(dp));
                	FOR(i,1,n+1)
                	cin>>weight[i]>>price[i];
                	cout<<solve(n,0);
                }

Measured memory_bytes: 82304
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include <algorithm>
#include<math.h>
using namespace std;

int main(){
  unsigned long n,m;
  cin >> n;
  m = n;
  unsigned long i = 1;
  vector<pair<unsigned long,unsigned long> > c;

  while(i <= sqrt(n) ){
    if(n%i == 0){
      c.push_back(pair<int,int>(to_string(i).size(),to_string(n/i).size()));
    }
      i++;
  }
  for(int i = 0 ; i < c.size();i++){
     m = min(m,max(c[i].first,c[i].second));
  }
  cout << m  << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
#隣接リスト
print("Yes")
g = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  #0-indexにします
  g[a-1].append(b-1)
  g[b-1].append(a-1)
q = deque([])
q.append(0)
check = [0] * n
while len(q) > 0:
  e = q.popleft()
  for i in g[e]:
    if check[i] > 0:
      continue
    check[i] = e + 1
    q.append(i)
for i in range(1,n):
  print(check[i])

Measured memory_bytes: 98940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{    iso;
 int n;cin>>n;
 string s;
 cin>>s; 
  int dp[4000][3];
   memset(dp,0,sizeof(dp));
    int r=0,b=0,g=0;
    
	if(s[n-1]=='R')dp[n-1][0]=1;
    else if(s[n-1]=='B')dp[n-1][1]=1;
	else dp[n-1][2]=1;
	 
    for(int i=n-2;i>=0;i--){
	 if(s[i]=='R')dp[i][0]=dp[i+1][0]+1; else dp[i][0]=dp[i+1][0];
     if(s[i]=='B')dp[i][1]=dp[i+1][1]+1; else dp[i][1]=dp[i+1][1];
     
	  if(s[i]=='G') dp[i][2]=dp[i+1][2]+1; else dp[i][2]=dp[i+1][2]; 
	}
	ll ans=0;
	f(i,0,n-2){
	
		f(j,i+1,n-1){
	     
		   if(s[i]=='R'){
		   	    if(s[j]=='B'){
		   	    	 if(2*j-i<n&&2*j-i>1)ans-=dp[2*j-i][2];
		   	    	 if(2*j-i<n-1)ans+=dp[2*j-i+1][2];
		   	    	 ans+=dp[j+1][2];
				   }
		   	    if(s[j]=='G'){
		   	    	if(2*j-i<n&&2*j-i>1)ans-=dp[2*j-i][1];
		   	    	 if(2*j-i<n-1)ans+=dp[2*j-i+1][1];
		   	    	ans+=dp[j+1][1];
				
				}
		   }
		   if(s[i]=='B'){
		   	    if(s[j]=='G'){
		   	    	 if(2*j-i<n&&2*j-i>1)ans-=dp[2*j-i][0];
		   	    	 if(2*j-i<n-1)ans+=dp[2*j-i+1][0];
		   	    	ans+=dp[j+1][0];
				   }
		   	    if(s[j]=='R'){
		   	    	if(2*j-i<n&&2*j-i>1)ans-=dp[2*j-i][2];
		   	    	 if(2*j-i<n-1)ans+=dp[2*j-i+1][2];
		   	    	ans+=dp[j+1][2];
				
				}
		   }
		   if(s[i]=='G'){
		   	    if(s[j]=='B'){
		   	    	 if(2*j-i<n&&2*j-i>1)ans-=dp[2*j-i][0];
		   	    	 if(2*j-i<n-1)ans+=dp[2*j-i+1][0];
		   	    	ans+=dp[j+1][0];
				   }
		   	    if(s[j]=='R'){
		   	    	if(2*j-i<n&&2*j-i>1)ans-=dp[2*j-i][1];
		   	    	 if(2*j-i<n-1)ans+=dp[2*j-i+1][1];
		   	    	ans+=dp[j+1][1];
				
				}
		   }		
		}
	
	}
		cout<<ans;
}


Measured memory_bytes: 3700
// A - Frog 1 / ATCODER
// Time Limit: 2 sec / Memory Limit: 1024 MB
// Score : 
// 100
//  points
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n+1];
	for(ll p=1;p<=n;p++)
	{
		cin>>a[p];
	}
	ll dp[100002]={0};
	dp[2]=abs(a[2]-a[1]);
	if(n==2)
	{
		cout<<dp[2]<<endl;
		return 0;
	}
	for(ll k=3;k<=n;k++)
	{
		dp[k]=min((abs(a[k]-a[k-1])+dp[k-1]),(abs(a[k]-a[k-2])+dp[k-2]));	
	}
	cout<<dp[n]<<endl;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int main()
{
	ios::sync_with_stdio(0);
	ll N=1,n,k;
	long double ans=0.0;
	cin >> N >> k;
	rep(n,1,N)
	{
		ll val=1,tmp=n;
		while(tmp<k) val*=2, tmp*=2;
		ans += (1.0/(N*val));
	}
	cout << setprecision(12) << fixed << ans << "\n";
	return 0;
}


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

using namespace std;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        for (int i = 0; i < k; i++) {
            cout << s.at(i);
        }
        cout << "..." << endl;
    } else {
        cout << s << endl;
    }
    return 0;
}


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

int main() {
  int N;
  string s;
  cin>>N;
  for(int i; i<N; i++){
    cin>>s;
    if(s=="Y"){
    cout<<"Four"<<endl;
    break;
    }
    if(!(i==N-1))
      continue;
    cout<<"Three"<<endl;
  }
}


Measured memory_bytes: 256
import collections
n,x,y=map(int,input().split())
lst=[]
num=[0]*(n+1)
for i in range(1,n):
  for j in range(i+1,n+1):
    k=min(abs(i-j),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))
    if num[k]==0:
      num[k]+=1
    lst.append(k)
    
Lst=list(collections.Counter(lst).items())
key=0
for i in range(1,n):
  if num[i]==0:
    print(0)
  else:
    print(Lst[key][1])
    key+=1

Measured memory_bytes: 119668
#include <bits/stdc++.h>
using namespace std ; 
#define ll              long long int
// #define cini(x)	        scanf("%lld",&x)
// #define cins(s)	        scanf("%s",s)
#define deb(x)          cout << (x) << "  " ;
#define out(x)          cout << (x) << endl ;
#define endl            '\n'
#define pb              push_back
#define mk              make_pair
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define loop(x,n,v)     for(ll v=x; v<n; v++)
#define loopr(n,x,v)     for(ll v=n-1; v>=x; v--)
#define mod             1000000007
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define PI              3.1415926535897932384626
#define setbits(x)      __builtin_popcount(x)
#define zrobits(x)      __builtin_ctz(x)
#define ps(x,y)         fixed << setprecision(y) << (x)
#define w(t)            int t; cin>>t; while(t--) 
#define     vi          vector<ll>
#define     vtt         vector<pair<ll,ll>> 
#define     pii         pair<ll,ll> 
#define  mapp           map<ll,ll> 
#define  sett           set<ll>
// int dp[1000][1000] ;
ll mpow(ll base, ll exp); 
// =================================
// =================================





int main(){
    fastio ;
    // w(t)
    // {
        ll a=0, b=0, c=0, d=0, e=0, p=0, q=0, r=0 ;
        ll ans=0, res=0, cnt=0, sum=0, diff=0, mul=1, val=0, k=0 ;
        // loop(0,n,i) brr[i]=0;
        // char s[100005];
        string s2 , s1, s3=" " ;
        ll n,m ;
        cin >> s1 >> s2 ;
        n = s1.length();
        m = s2.length();
        ll arr[n+1], brr[m+1] ,dp[n+1][m+1];
        clr(dp);
        // loop(0,n,i) cin >> arr[i] ;
        loop(0,n+1,i){
            p=0;
            loop(0,m+1,j){
                if(i==0 || j==0)    dp[i][j]=0;
                else{
                    if(s1[i-1] == s2[j-1] ){
                        dp[i][j] = 1 + dp[i-1][j-1];
                        // s3 += s1[i-1];
                        // p=1;
                        // break;
                        // deb("sdsv");
                    }
                    else
                        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                }
                // cout << dp[i][j] <<" ";
            }
            // out("")
        }
        int i=n, j=m ;
        s3=" ";
        while(i > 0 && j > 0){
            if(s2[j-1] == s1[i-1]){
                s3 = s2[j-1]+s3  ;
                i--;
                j--;
            }
            else{
                if(dp[i-1][j] > dp[i][j-1]) i--;
                else j--;
            }
        }
        out(s3)
    // }
    return 0 ;
}

// g++ x.cpp -o as && ./as

Measured memory_bytes: 74008
import itertools

n = int(input())
x = []
y = []

for i in range(n):
    x_, y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)

li = list(range(n))
p = list(itertools.permutations(li))
di = 0
for i in p:
    i = list(i)

    for j in range(len(i)-1):
        xd = x[i[j]] - x[i[j + 1]]
        yd = y[i[j]] - y[i[j + 1]]
        di += (xd**2 + yd**2)**0.5

print(di/len(p))


Measured memory_bytes: 8180
#include <stdio.h>
int main(void)
{int A,B,C,a,b,c,D,X;
scanf("%d",&A);
scanf("%d",&B);
scanf("%d",&C);
scanf("%d",&X);
D=0;
for(a=0;a<=A;a++){
for(b=0;b<=B;b++){
for(c=0;c<=C;c++){
if(500*a+100*b+50*c==X){
D=D+1;}}}}
printf("%d",D);
 
 
 
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  ll D, N;
  cin >> D >> N;
  if(N==100) N++;
  ll ans = pow(100, D) * N;
  
  cout << ans;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  int a, b;
  cin >> a >> b;
  int out = 1;
  int sum = 0;
  while (out < b)
  {
    out += a;
    out--;
    sum++;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
ll n,k;cin>>n>>k;
ll h[n];
rep(i,n)cin>>h[i];
sort(h,h+n,greater<int>());
ll ans=0;
for(int i=k;i<n;i++){
    ans+=h[i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 1792
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let (N, M, P) = get!(usize, usize, i64);
    let ABC = get!(usize, usize, i64; M);

    // ベルマンフォード法により解を求める
    let INF = 1000000000000;
    let mut dp = vec!(INF; N + 1);
    dp[1] = 0;
    for k in 0..2*N {
        for i in 0..M {
            let (a, b, c) = ABC[i];
            let w = P - c;
            if dp[a] < INF && dp[b] > dp[a] + w {
                dp[b] = dp[a] + w;
                if k >= N - 1 {
                    dp[b] = -INF;
                }
            }
        }
    }
    let ans = if dp[N] == -INF {
        -1
    } else if dp[N] <= 0 {
        -dp[N]
    } else {
        0
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
	int i, j, l;
	int v, n,a;
	while (1) {
		a = 0;
		cin >> n; cin >> v;
		if (v == 0 && n == 0)break;
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= i; j++) {
				for (l = 1; l <= j; l++) {
					if (v == i + j + l && i != j && j != l && i != l) { 
						//cout << i<<j<<l<<"\n";
						a++; }
				}
			}
		}
		cout << a<<"\n";




	}



}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 87, D = 105, C = 10, MOD = 1e9 + 7;
string s;
int d, dp[N][D][C];
int main()
{
    cin >> s >> d;
    int n = s.size();
    dp[0][0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < d; ++j) {
            for (int k = 1; k < C; ++k)
                (dp[i][j][k] += dp[i][j][k - 1]) %= MOD;
            for (int k = 0; k < C; ++k)
                (dp[i + 1][(j + k) % d][k] += dp[i][j][C - 1]) %= MOD;
        }
    }
    reverse(begin(s), end(s));
    int ps = 0, ans = 0;
    for (int i = n; i >= 1; --i) {
        int c = s[i - 1] - '0';
        if (c)
            (ans += dp[i][(d - ps) % d][c - 1]) %= MOD; // x < k
        ps = (ps + c) % d;
    }
    ans += ps == 0; // x == k
    ans += MOD - 1; // x == 0
    cout << ans % MOD << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int x;
	cin>> x;

	if(x<600) cout<< "8" << endl;
	else if(x<800) cout<< "7" << endl;
	else if(x<1000) cout<< "6" << endl;
	else if(x<1200) cout<< "5" << endl;
	else if(x<1400) cout<< "4" << endl;
	else if(x<1600) cout<< "3" << endl;
	else if(x<1800) cout<< "2" << endl;
	else cout<< "1" << endl;
 
	return 0;
}

Measured memory_bytes: 3640
H,W = map(int,input().split())
S = [[1]*(W+2)]
for _ in range(H):
    tmp = [1]
    [tmp.append(int(c=="#")) for c in input()]
    tmp.append(1)
    S.append(tmp)
S.append([1]*(W+2))
       
ans = 0
for w in range(W+2):
    for h in range(H+2):
        if S[h][w]==0:  
            ans += 1

Q = [[1,1,1]]
S[1][1] = 1

def Step():
    while Q:
        q = Q.pop(0)
        if q[0]==H and q[1]==W:
            return(q[2])
        else:
            for M in [[-1,0],[1,0],[0,-1],[0,1]]:
                if S[q[0]+M[0]][q[1]+M[1]] == 0:
                    S[q[0]+M[0]][q[1]+M[1]] = 1
                    Q.append([q[0]+M[0],q[1]+M[1],q[2]+1])
    else:           
        return(-1)
    
step = Step()
if(step==-1):  
    print(-1)
else:
    print(ans-step)  


Measured memory_bytes: 40304
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<ll>>;

// dijkstra　
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
// dijkstra end


class UnionFind
{
public:
  ll par[100005];
  ll depth[100005];
  ll nGroup[100005];
 
  UnionFind(ll n) {
    init(n);
  }
 
  void init(ll n) {
    for(ll i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  ll root(ll x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(ll x, ll y) {
    return root(x) == root(y);
  }
 
  void unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
// unionfind end

// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];

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

// nCr end

// tree DP
vector<ll> depth;
vector<ll> g(10010,0);
ll c[10010];
void dfs(const Graph &G, ll v, ll p, ll &d) {
         g[v] = c[d-1];
    for (auto nv : G[v]) {
        if (nv == p) continue;
        d--;
        dfs(G, nv, v, d);
    }
}
// tree DP end
int main() {
  ll n; cin>>n;
  ll a[n]={};
  rep(i,n) cin>>a[i];
  if(n==1) {
    cout << a[0] << endl;
    return 0;}
  ll ans = 0;
  ll lms = 0;
  ll g = __gcd(a[0],a[1]);
  lms = a[0]/g*a[1];
  repl(i,2,n){
    g = __gcd(lms,a[i]);
    lms = lms/g*a[i];
  } 
  cout << lms << endl;
}
      


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		
		int V[] = new int[N];
		for(int i = 0; i < N; i++) {
			V[i] = stdIn.nextInt();
		}
		int C[] = new int[N];
		for(int j = 0; j < N; j++) {
			C[j] = stdIn.nextInt();
		}
		
		int max = 0;
		for(int k = 0; k < N; k++) {
			if(V[k] > C[k]) {
				max += (V[k]-C[k]);
			}
		}
		System.out.println(max);

	}

}

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

char mozi[26];

int main(void) {
	char c;
	long int len, i;
	char str[100000];

	for(c = 'a'; c <= 'z'; c++) {
		mozi[c - 'a'] = c;
	}

	gets(str);
	for(i = 0; i < 100000 && str[i] != '\0'; i++) {
		mozi[str[i] - 'a'] = 'A';
	}

	for(i = 0; i < 26; i++) {
		if(mozi[i] != 'A') {
			printf("%c", mozi[i]);
			return 0;
		}
	}

	printf("None");

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    h=sorted([int(input()) for i in range(n)])
    ans=10**20
    for i in range(n-k+1):
        ans=min(ans,h[i+k-1]-h[i])
    print(ans)


resolve()

Measured memory_bytes: 45148
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if (x < d)
	{
		if (k % 2 == 0)cout << x;
		else cout << abs(x - d);
	}
	else
	{
		if (k < x / d) {
			cout << x - k*d;
		}
		else if (k == x / d)cout << x%d;
		else {
			if ((k - (x/d)) % 2 == 0)cout << x%d;
			else cout << abs(x%d - d);
		}
	}
}

Measured memory_bytes: 3596
#include <iostream>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main(){
  ll N, M, tmp;
  unordered_set<ll> broken;
  cin >> N >> M;
  for (int i=0; i<M; i++){
    cin >> tmp;
    broken.insert(tmp);
  }
  ll ans = 0, tol = 0;
  vector<ll> his;
  his.push_back(1);
  for (int i=1; i<=N; i++){
    ll tmp2 = 0;
    tol = 0;
    if (broken.find(i) == broken.end()){
      for (int j=i-2; j<i; j++){
        if (j >= 0 && broken.find(j) == broken.end()){
          tmp2 = (tmp2 + his[j]) % mod;
        }
      }
    }
    his.push_back(tmp2);
  }
  cout << his.back() << endl;
  return 0;
}

Measured memory_bytes: 5924
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main()


{
  string s;
  while(getline(cin,s)){

    //s = s.substr(0,s.length()-1);
    stack<char> q;
    bool ret = true;

    for(int i = 0; i < (int)s.length(); ++i){

      if(i>0&&q.empty() ){
        ret = false;
        break;
      }

      /*
        stack<char> cur=q;
        string tt;
        while(!cur.empty()){
        tt+=cur.top();cur.pop();
        }
        reverse(tt.begin(),tt.end());
        cout << tt << ' ' << '<' << s[i] << endl;
      */

      if(s[i]=='w'){

        if(q.size()<2){
          ret=false;
          break;
        }

        char t1 = q.top();
        q.pop();
        char t0 = q.top();
        q.pop();
      
        //cout << t1 << ' ' << t0 << endl;
      
        if(!(t1=='e'&&t0=='m')){
          ret = false;
          break;
        }

      }else{
        if(s[i]=='m'||s[i]=='e'){
          q.push(s[i]);
        }else{
          ret = false;
          break;
        }
      }
    
    }

    if(ret){
      ret = q.empty();
    }
  
    if(ret){
      cout <<"Cat"<<endl;
    }else{
      cout<<"Rabbit"<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    char b; cin >> b;

    if(b == 'A') {
        cout << 'T' << endl;
    } else if (b == 'T') {
        cout << 'A' << endl;
    } else if (b == 'G') {
        cout << 'C' << endl;
    } else if (b == 'C') {
        cout << 'G' << endl;
    } 

    return 0;
}



Measured memory_bytes: 256
from collections import deque

S = deque(list(str(input())))
Q = int(input())
flag = False

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        flag = not(flag)
    else:
        if(int(Query[1]) == 1):
            if(flag):
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
        else:
            if(flag):
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

if(flag):
    S.reverse()

print("".join(list(S)))

Measured memory_bytes: 8676
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long 
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int n,m;
string a[1005];
int dp[1005][1005];

signed main() {
    FASTIO;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("stderr.txt", "w", stderr);
    // #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        cin>>n>>m;
        rep(i,n) cin>>a[i];
        bool b=true;
        rep(j,m){
            if(a[0][j]=='#') b=false;
            dp[0][j]=(b==true);
        }
        b=true;
        rep(i,m){
            if(a[i][0]=='#') b=false;
            dp[i][0]=(b==true);
        }
        loop(i,1,n){
            loop(j,1,m){
                if(a[i][j]=='#') dp[i][j]=0;
                else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
        // rep(i,n){ rep(j,m) cerr<<dp[i][j]<<' '; cerr<<endl;}
        cout<<dp[n-1][m-1]<<endl;
        
    // }
    cerr<<"Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec";
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
ll x[maxn],v[maxn],sum_v[maxn];
ll seg[maxn*4];
void modify(int l,int r,int pos,ll val,int idx){
	if(l==r) seg[idx]=val;
	else{
		int mid=(l+r)>>1;
		if(pos<=mid) modify(l,mid,pos,val,idx<<1);
		else modify(mid+1,r,pos,val,idx<<1|1);
		seg[idx]=max(seg[idx<<1],seg[idx<<1|1]);
	}
}
ll query(int l,int r,int ql,int qr,int idx){
	if(l==ql && r==qr) return seg[idx];
	int mid=(l+r)>>1;
	if(qr<=mid) return query(l,mid,ql,qr,idx<<1);
	else if(ql>mid) return query(mid+1,r,ql,qr,idx<<1|1);
	return max(query(l,mid,ql,mid,idx<<1),query(mid+1,r,mid+1,qr,idx<<1|1));
}
int main(){
	int n;
	ll c;
	scanf("%d%lld",&n,&c);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",x+i,v+i);
		sum_v[i]=sum_v[i-1]+v[i];
	}
	for(int i=1;i<=n;i++)
		modify(1,n,i,sum_v[n]-sum_v[i-1]-(c-x[i]),1);
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,sum_v[i]-x[i]);
		if(i<n) ans=max(ans,sum_v[i]-x[i]-x[i]+query(1,n,i+1,n,1));
	}
	reverse(x+1,x+1+n);
	reverse(v+1,v+1+n);
	for(int i=1;i<=n;i++){
		x[i]=c-x[i];
		sum_v[i]=sum_v[i-1]+v[i];
	}
	for(int i=1;i<=n;i++)
		modify(1,n,i,sum_v[n]-sum_v[i-1]-(c-x[i]),1);
	for(int i=1;i<=n;i++){
		ans=max(ans,sum_v[i]-x[i]);
		if(i<n) ans=max(ans,sum_v[i]-x[i]-x[i]+query(1,n,i+1,n,1));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760