akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define num(x,y) (x*1000+y)
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
int pa[N];
int h,w;
string s[1005];
int d[N];
int find(int i){
	if(pa[i]==i)return i;
	return pa[i]=find(pa[i]);
}
void join(int i,int j){
	int a=find(i);
	int b=find(j);
	pa[a]=b;
}
bool check(int i,int j){
	return i>=0&&j>=0&&i<h&&j<w&&s[i][j]=='.';
}
void solve(){
	cin>>h>>w;
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--;
	cw--;
	dh--;
	dw--;
	for(int i=0;i<N;i++)pa[i]=i;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#')continue;
			for(int k=0;k<4;k++){
				int x=dx[k]+i;
				int y=dy[k]+j;
				if(check(x,y)){
					int p1=find(num(x,y));
					int p2=find(num(i,j));
					if(p1==p2)continue;
					join(p1,p2);
				}
			}
		}
	}
	int src=find(num(ch,cw));
	int dest=find(num(dh,dw));
	set<int>ed[N];
	if(src==dest){cout<<0;return;}
	for(int x=0;x<h;x++)for(int y=0;y<w;y++){
		if(s[x][y]=='#')continue;
		int i=find(num(x,y));
		//cout<<i<<" ";
		for(int j=-2;j<=2;j++)for(int k=-2;k<=2;k++){
			int x1=x+j;
			int y1=y+k;
			if(check(x1,y1)){
				int p1=i;
				int p2=find(num(x1,y1));
				if(p1==p2)continue;
				//cout<<p1<<" "<<p2<<"\n";
				ed[p1].insert(p2);
				ed[p2].insert(p1);
				//join(p1,p2);
			}
		}
	}
	for(int i=0;i<N;i++)d[i]=inf;
	d[src]=0;
	//cout<<find(num(ch,cw))<<"c\n";
	queue<int>q;
	q.push(src);
	while(!q.empty()){
		int u=q.front();
		int dd=d[u];
		q.pop();
		for(int v:ed[u]){
			if(dd+1<d[v]){
				d[v]=1+dd;
				q.push(v);
			}
		}
	}
	if(d[dest]>=inf)cout<<-1;
	else cout<<d[dest];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 77868
import sys
sys.setrecursionlimit(200000)

N=int(input())
to=[[] for _ in range(N)]
color=[0 for _ in range(N)]
for i in range(N-1):
    u, v, w=map(int, input().split())
    u-=1
    v-=1
    to[u].append([v, w%2])
    to[v].append([u, w%2])

def dfs(v, p=-1, c=0):
    for i in range(len(to[v])):
        u, w=to[v][i]
        if p==u:
            continue
        color[u]=(c+w)%2
        dfs(u, v, color[u])

dfs(0)
for i in range(N):
    print(color[i])

Measured memory_bytes: 157088
#include<iostream>
using namespace std;
int main()
{
    int a;
    cin >> a;
    int tmp,cnt=0, b[a];
    while (cin>>tmp) {
      b[cnt] = tmp;
      cnt++;
    }

    for (int i=0;i<a;i++) {
      if (b[i] % 2 == 0) {
        if (b[i] % 3 != 0 && b[i] % 5 != 0) {
          cout << "DENIED" << endl;
          return 0;
        }
      }
    }

    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);

if(a==b) puts("Draw");
else
if(a==1) puts("Alice");
else
if(b==1) puts("Bob");
else
if(a<b) puts("Bob");
else
if(a>b) puts("Alice");



return 0;


}

Measured memory_bytes: 128
S=input()
T=input()
n=len(S)
m=len(T)

for i in range(n-m,-1,-1) :
    x=S[i:i+m]
    for j in range(m+1):
        if j==m :
            print((S[:i]+T+S[i+m:]).replace("?","a"))
            exit()
        if x[j]=="?" :
            continue
        elif x[j]!=T[j] :
            break
 
print("UNRESTORABLE")


Measured memory_bytes: 9156
A = input()
a = int(A)
B = input()
C = input()
res1 = tuple()
res2 = tuple()
from itertools import permutations 
l = list(permutations(range(1, a+1))) 
res1 = tuple(map(int, B.split(' ')))
res2 = tuple(map(int, C.split(' ')))
d = l.index(res1)
e = l.index(res2)
print(abs(d-e))


Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	long long n;
	cin >> n;
	for(long long i = 1; i <= 3600; i++){
		for(long long j = 1; j <= 3600; j++){
			if(4 * i * j - n * j - n * i == 0) continue;
			if((n * i * j) % (4 * i * j - n * j - n * i) == 0){
				long long tmp = (n * i * j) / (4 * i * j - n * j - n * i);
				if(tmp > 0){
					cout << i << ' ' << j << ' ' << tmp << endl;
					return 0;
				}
			}
		}
	}
	assert(false);
}


Measured memory_bytes: 384
#! /usr/bin/env python3

N = int(input())
L = sorted(map(int, input().split()))[::-1]
a = 0
b = 0
while L:
    t = L.pop(0)
    if a == t:
        break
    else:
        a = t
while L:
    t = L.pop(0)
    if b == t:
        break
    else:
        b = t
    
print(a*b)

Measured memory_bytes: 14244
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (x, y, z, k) = (line[0], line[1], line[2], line[3]);
    
    let mut ab: Vec<u64> = Vec::new();

    let a: Vec<u64> = read_as_vec();
    let b: Vec<u64> = read_as_vec();

    for i in 0..x{
        for j in 0..y{
            ab.push(a[i]+b[j]);
        }
    }

    //println!("{:?}",ab);
    ab.sort_by_key(|x| -(*x as i64));
    //println!("{:?}",ab);

    let ab: Vec<u64> = ab.into_iter().take(k).collect::<Vec<u64>>();
    
    //println!("{:?}",ab);

    let c: Vec<u64> = read_as_vec();
    let mut abc: Vec<u64> = Vec::new();
    for i in 0..ab.len(){
        for j in 0..z{
            abc.push(ab[i]+c[j]);
        }
    }

    abc.sort_by_key(|x| -(*x as i64));

    for i in 0..k{
        println!("{}", abc[i]);
    }
}


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

int main(void){
  int n, k, num = 1, i;
  cin >> n >> k;
  for(i = 0; i < n; i++){
    if(num < k) num *= 2;
    else num += k;
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp((1 << V), vector<int>(V, -1));
	function<int(int, int)>tsp = [&](int S, int v) {
		if (dp[S][v] != -1)return dp[S][v];
		if (S == (1 << V) - 1 && v == 0)return dp[S][v] = 0;
		int ret(INF);
		rep(i, 0, V) {
			if (!(S&(1 << i))) {
				chmin(ret, tsp(S | (1 << i), i) + G[v][i]);
			}
		}
		return dp[S][v] = ret;
	};
	int ans = tsp(0, 0);
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 6208
#include<iostream>
using namespace std;
int main(){
  string s;
  int a,b,c,d,ind;
  cin >> s;
  while(s!="#"){
    int h=0,e_size;
    cin >> a >> b >> c >> d;
    string s_map[10];
    string ans;
    fill(s_map,s_map+10,"");
    for(int i=0;i<s.size();i++){
      if(s[i]=='/'){
        h++;
      }else if(s[i]=='b'){
        s_map[h]+='b';
      }else{
        e_size=(s[i]-'0');
        while(e_size!=0){
          s_map[h]+='.';
          e_size--;
        }
      }
    }
    a--; b--; c--; d--;
    if(s_map[a][b]=='b'){
      s_map[a][b]='.';
      s_map[c][d]='b';
    }
    for(int i=0;i<=h;i++){
      for(int j=0;j<s_map[i].size();j++){
        if(s_map[i][j]=='b'){
          ans+='b';
        }else{
          ind=j;
          while(ind<s_map[i].size()&&s_map[i][ind]=='.'){
            ind++;
          }
          ans+=to_string(ind-j);
          j=ind-1;
        }
      }
      if(i!=h)ans+='/';
    }
    cout << ans<<endl;
    cin >> s;
  }
}



Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

const int N = 20;

int n, U, C[N], K[N], R[N];
bool vis[1<<N];

int solve(){
  queue<P> q;
  q.push(P(0, 0));
  fill(vis, vis+(1<<n), false);
  while(!q.empty()){
    P u = q.front(); q.pop();
    if(u.second >= U){
      int res = 0;
      for(int i=0;i<n;i++) if((u.first >> i) & 1) res++;
      return res;
    }
    if(vis[u.first]) continue;
    vis[u.first] = true;
    for(int i=0;i<n;i++){
      if(!((u.first >> i) & 1) && (u.first & R[i]) == R[i]){
        q.push(P(u.first | (1<<i), u.second + C[i]));
      }
    }
  }
}

main(){
  while(scanf("%d %d", &n, &U) && (n|U)){
    for(int i=0;i<n;i++){
      scanf("%d %d", &C[i], &K[i]);
      R[i] = 0;
      for(int j=0;j<K[i];j++){
        int r;
        scanf("%d", &r);
        R[i] |= 1 << r;
      }
    }
    printf("%d\n", solve());
  }
}

Measured memory_bytes: 18476
#include <stdio.h>

int main()
{
    long int X;
    scanf("%d", &X);

    long int count500, count5;
    count500 = X / 500;

    count5 = (X - count500 * 500) / 5;
    printf("%d\n", count500*1000+count5*5);

    return 0;
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
 
signed main(){
	cin>>n;
	int ans,x=n,cnt=0;
	int cnt2=0;
	bool can=true;
	while(x){
	    if(x%10!=9)can=false;
	    cnt+=x%10;
	    if(x<10&&!can)cnt2+=x-1;
	    else cnt2+=9;
	    x/=10;
	}
	
	ans=max(cnt,cnt2);
	cout<<ans<<endl;
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
let calc op a b = op (int_of_string a) (int_of_string b)

let eval s = 
  s |> Str.split (Str.regexp " ") |>
  (function | [a; "+"; b] -> calc (+) a b
            | [a; "-"; b] -> calc (-) a b
            | [a; "*"; b] -> calc ( * ) a b
            | [a; "/"; b] -> calc (/) a b
            | _ -> failwith "illegal input")

let rec loop () =
  match read_line () with
  | s when String.contains s '?' -> ()
  | expr -> loop (print_int (eval expr); print_newline ())

let () = loop ()

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

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

d = 0
for i in range(n):
  if a[i] >= b[i]:
    d += b[i]

  else:
    d += a[i]
    b[i] = b[i] - a[i]
    
    if a[i+1] - b[i] >= 0:
      d += b[i]
      a[i+1] = a[i+1] - b[i]
      
    else:
      d += a[i+1]
      a[i+1] = 0
      
      
print(d)

Measured memory_bytes: 19156
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
const ll mod = 1000000007;

int pp_s[100000]={0};

int pp(int n){
	if(n<3) return 0;
	else if(n==3) return 1;
	else if(pp_s[n]) return pp_s[n];
	else {
		int r=1;
		for(int i=n-3; i>=3; i--) {
			r = (r+pp(i))%mod;
		}
		pp_s[n] = r;
		return r;
	}
}

int main(){
	int s;
	scanf("%d", &s);
	printf("%d\n", pp(s));
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
    freopen ("E.in", "r", stdin);
    freopen ("E.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n;

pair<int, int> a[N];

multiset<int> R, B;

#define Max(S) *S.rbegin()
#define Min(S) *S.begin()

int main() {

	File();

	n = read();
	For (i, 1, n) {
		int x = read(), y = read(); if (x > y) swap(x, y);
		B.insert(x); R.insert(y); a[i] = make_pair(x, y);
	}
	long long ans = 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B));

	sort(a + 1, a + n + 1);
	For (i, 1, n) {
		B.erase(B.find(a[i].first)); R.insert(a[i].first);
		R.erase(R.find(a[i].second)); B.insert(a[i].second);
		chkmin(ans, 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B)));
	}
	printf ("%lld\n", ans);

	return 0;

}

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

long long gcd(long long y, long long x){
	if(x==0)return y;

	return gcd(x,y%x);

}

signed main(){
	long long a,b;	cin>>a>>b;
	if(a<b)swap(a,b);
	cout<<a*b/gcd(a,b)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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


    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='?'){
            s[i]='D';
        }
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 3720
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

const int N = 100003;

ll ans = 0;
int n, a[N * 3];

int main() {
	scanf("%d", &n); n *= 3;
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	stable_sort(a + 1, a + n + 1);
	int top = n / 3, tmp = n + 1, tot = 0;
	while (tot < top) {
		tmp -= 2;
		ans += a[tmp];
		++tot;
	}
	cout << ans << endl;
	return 0;
}

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

        int n = sc.nextInt();
        int[] arr = new int[2*n];
        for(int i = 0; i < 2*n; i++){
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int ans = 0;
        for(int i = 2*n - 1; i > 0; i -= 2){
            ans += Math.min(arr[i], arr[i-1]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n,k;cin>>n>>k;
    if(k==1)
        cout<<0;
    else
        cout<<(n-(k-1)-1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=1e5+500;
const ll mod=1e9+7;
const ll inf=2e9+500;

ll x[maxn];
ll par[maxn][20];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x[i];
    }
    x[n]=inf;
    ll l,q;
    cin>>l>>q;
    for(ll i=0;i<n;i++){
        par[i][0]=upper_bound(x,x+n+1,x[i]+l)-(&x[0])-1;
    }
    for(ll j=1;j<20;j++){
        for(ll i=0;i<n;i++){
            par[i][j]=par[par[i][j-1]][j-1];
        }
    }
    while(q--){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;

        if(a>b)swap(a,b);
        ll ans=0;
        for(ll i=19;i>=0;i--){
            if(par[a][i]<b){
                ans+=(1<<i);
                a=par[a][i];
            }
        }
        ans++;
        cout<<ans<<endl;
    }

}



Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
const ll mod=1000000007;

bool sosuu(int a){
  bool flag2=true;
  for(int i = sqrt(a);i>1;i--){
    if(a%i==0){
      flag2=false; break;
    }
  }
  return flag2;
}

int main(){
  ll n,ans=1,count=0,p;
  cin >> n;
  r(i,n){
    if(i==0)continue;
    if(sosuu(i+1)){
      p=i+1;
      while(p<=n){
        count+=n/p;
        p*=i+1;
      }
      ans*=count+1;
      ans%=mod;
      
      count=0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

long long *fact, *inv;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

void init_factorial(int n, long long mod) {
    fact = new long long[n + 1];
    inv = new long long[n + 1];
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    i64 n, x;
    constexpr i64 mod = 998244353;
    std::cin >> n >> x;
    init_factorial(n, mod);
    std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(2 * n + 10));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) for (int j = 0; j <= 2 * n; j++) {
        dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j]) % mod;
        dp[i][j + 2] = (dp[i][j + 2] + dp[i - 1][j]) % mod;
    }
    i64 ret = 0;
    for (int i = 0; i <= n; i++) for (int j = 0; j < x; j++) {
        ret = (ret + dp[i][j] * fact[n] % mod * inv[i] % mod * inv[n - i] % mod) % mod;
    }
    for (int i = 1; i * 2 <= x - 1; i++) for (int j = i; j + i <= n; j++) {
        ret = (ret + dp[j - i][x - i * 2 - 1] * fact[n] % mod * inv[j + i] % mod * inv[n - j - i] % mod) % mod;
    }
    if (x % 2) {
        for (int i = x; i <= n; i++) {
            ret = (ret + fact[n] * inv[i] % mod * inv[n - i] % mod) % mod;
        }
    }
    std::cout << ret << std::endl;

    return 0;
}


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

int calc( int a )
{
    if( a == 0 )
        return 0;
    return a - 1 + calc( a - 1 );
}

int main()
{
    int n, s, r, a[101];

    while( cin >> n >> s )
    {
        if( n + s == 0 )
            break;

        for( int i = 0; i < 101; i++ )
            a[i] = 0;

        for( int i = 0; i < n; i++ )
        {
            cin >> r;
            a[r]++;
        }

        int cnt = 0;
        for( int i = 1; i < 100; i++ )
            for( int j = i + 1; j < 101; j++ )
                if( i + j > s )
                    cnt += a[i] * a[j];

        for( int i = 1; i < 101; i++ )
            if( i + i > s )
                cnt += calc(a[i]);

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
s=n.times.map{
  inp=gs
  h[inp]+=1
}

ar=h.to_a.sort{|x,y| y[1]<=>x[1]}
cnt=ar[0][1]
puts ar.select{|a|a[1]==cnt}.map{|a|a[0]}.sort

Measured memory_bytes: 44136
N = int(input())
L = [0] * N
for i in range(N):
    L[i] = int(input())

ten = []
non = []
for i in L:
    if i % 10 == 0:
        ten.append(i)
    else:
        non.append(i)
if (sum(ten) + sum(non))%10 != 0:
    print(sum(ten) + sum(non))
elif non == []:
    print(0)
else:
    print((sum(ten) + sum(non))-min(non))

Measured memory_bytes: 38256
#! usr/bin/perl

use strict;
use warnings;

my @a;
my @b;
my @c;
my @d;

sub get_pos {
    my ($count,$x,$y) = @_;
    foreach my $i (0..$count-1) {
        chomp(my $line = <STDIN>);
        (@$x[$i],@$y[$i]) = split ' ',$line;
    }
}

chomp(my $line = <STDIN>);
my ($N,$M) = split ' ',$line;
&get_pos($N,\@a,\@b);
&get_pos($M,\@c,\@d);

my $MAX = 4*10**8+1;
foreach my $student (0..$N-1) {
    my $p = 0;
    my $min_dis = $MAX;
    foreach my $checkP (reverse 0..$M-1) {
        my $d = abs($a[$student]-$c[$checkP]) + abs($b[$student]-$d[$checkP]);
        unless ($d > $min_dis) {$min_dis = $d; $p = $checkP+1;}
    }
    print "$p\n";
}


Measured memory_bytes: 768
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	string S;
	cin >> N >> S;

	char c;
	int len = 0;
	size_t mx = 0;
	for (size_t i = 1; i < N; i++)
	{
		size_t k = 0;
		for (size_t j = 0; j + i < N; j++)
		{
			if (S[j] == S[j + i])
			{
				k++;
				mx = max(mx, min(i, k));
			} else {
				k = 0;
			}
			
		}
		
	}

	cout << mx << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
vector<int> a;
vector<int> G[100010];
bool ans = true;
int root = 0;

int dfs(int now, int pre){
    if(G[now].size() == 1) return a[now];
    int sum = 0;
    int cnt = 0, MAX = 0;
    rep(i, 0, G[now].size()){
        if(G[now][i] == pre) continue;
        int tmp = dfs(G[now][i], now);
        if(tmp > 0){
            sum += tmp;
            chmax(MAX, tmp);
            cnt++;
        }
    }
    if(pre == -1 && sum != 0 && a[now] != 0 && cnt < 2) ans = false;
    if(sum > 2 * a[now] || sum < a[now]) ans = false;
    if(a[now] < MAX) ans = false;
    return 2 * a[now] - sum;
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 0, n - 1){
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    if(n == 2){
        if(a[0] == a[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }
    rep(i, 0, n) if(G[i].size() != 1){root = i; break;}
    if(dfs(root, -1) != 0) ans = false;
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
 double N,K;
  in(N>>K);
  double ni = 1.00000000000000000000000/N;
  double wa =0.0000000000000000000000;
  for(int i=1;i<=N;i++){
    int kai =0;
    int w =i;
   while(w<K){
    w *= 2;
     kai++;
   }
    int s = pow(2,kai);
    wa += (1.0000000000000000000/s);
  }
  cout <<fixed<<setprecision(15)<<ni*wa<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

bool isFall(string &s, vector<pair<char, char>> &cmd, ll pos, char goal){
    bool ret = false;
    ll cmdSize = cmd.size();
    rep(i, cmdSize){
        // 現在位置が呪文の対象の場合
        if(cmd[i].first == s[pos]){
            cmd[i].second == 'R' ? pos++ : pos--;
            if(pos < 0 || pos > s.size()-1) break;
        }
    }
    if(pos < 0 && goal == 'L' || pos > s.size()-1 && goal == 'R') ret = true;
    return ret;
}

int main(){
    Init();
    ll n, q; string s;
    cin >> n >> q >> s;
    vector<pair<char, char>> cmd(q);
    rep(i, q) cin >> cmd[i].first >> cmd[i].second;

    // 左方向に落ちるゴーレムの中で最も右側にあるものを求める
    ll l = -1, r = n;
    while(r-l > 1){
        ll mid = (r+l)/2;
        (isFall(s, cmd, mid, 'L') ? l : r) = mid;
    }

    // 右方向に落ちるゴーレムの中で最も左側にあるものを求める
    ll ans = n-(l != -1 ? (l+1) : 0);
    l = -1, r = n;
    while(r-l > 1){
        ll mid = (r+l)/2;
        (isFall(s, cmd, mid, 'R') ? r : l) = mid;
    }
    cout << max(0LL, ans-(r != n ? (n-r) : 0))  << endl;
}

Measured memory_bytes: 3868
#include<stdio.h>
 int main(void)
 {
     int i,x[5];

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

     for(i=0;i<5;i++){
       if(x[i]==0){
         printf("%d\n",i+1);
         return 0;
       }
     }
 }


Measured memory_bytes: 1708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

int cou[2000000];

int N;
int K;
int a;
int kind = 0;
int main()
{
    cin >> N;
    cin >> K;
    for(int i = 0;i < N;i++)
    {
        cin >> a;
        if(cou[a - 1] == 0) kind++;
        cou[a - 1]++;
    }
    sort(cou,cou + N);

    int kc = 0;
    int ans = 0;
    for(int i = 0;i < N;i++)
    {
        if(kc >= kind - K) break;
        if(cou[i] != 0)
        {
            kc++;
            ans+=cou[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int m = in.nextInt();
        long[] a = new long[n];
        long sum = 0;
        for(int i = 0; i<n; i++){
            a[i] = in.nextLong();
            sum+=a[i];
        }
        Arrays.sort(a);
        int count = m;
        for(int i = n-1; i>=0; i--){
            if (m == 0) {
                break;
            }
            sum-=a[i];
            --m;
            if (m == 0) {
                break;
            }
        }
        out.println(sum);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 57292
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
use std::cmp::max;
fn main() {
    let a = read::<i64>();
    let b = read::<i64>();

    println!("{}", max(a+b, max(a*b, a-b)));
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int x, y, s;
	while (cin >> x >> y >> s, x || y || s) {
		int ans = 0;
		for (int i = 1; i < s; ++i) {
			for (int j = i; j <= s - i; ++j) {
				int ax = i * (100 + x) / 100;
				int bx = j * (100 + x) / 100;
				if (ax + bx == s) {
					int ay = i * (100 + y) / 100;
					int by = j * (100 + y) / 100;
					ans = max(ans, ay + by);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long A, B, C;

    cin >> A >> B >> C;

    long long d = C - A - B;
    if (d > 0 && 4 * A * B < d * d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	int lenS, lenT;
	lenS = s.length();
	lenT = t.length();

	int dp[lenS+1][lenT+1];
	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= lenS; ++i)
	{
		for (int j = 1; j <= lenT; ++j)
		{
			if (s[i-1] == t[j-1])
				dp[i][j] = 1 + dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}

	int length = dp[lenS][lenT];
	string ans = "";

	for (int i = lenS, j = lenT; i > 0 && j > 0; --i, --j)
	{
		if (s[i-1] == t[j-1])
			ans = s[i-1] + ans;
		else if (dp[i-1][j] > dp[i][j-1])
			++j;
		else
			++i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35456
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>

using namespace std;
using uint = uint32_t;
using LL = int64_t;
using ULL = uint64_t;
using PP = pair<LL, LL>;
template <typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#define REP(i, a, n) for(LL i = (a), i##_max_ = (n); i < i##_max_; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##_min_ = (a); i >= i##_min_; --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP { cin.tie(NULL); ios::sync_with_stdio(false); }
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U> ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template <class T> T Next() { T buf; cin >> buf; return buf; }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Algebraic.h"
#include "BinaryMatrix.h"
#include "BinaryTree.h"
#include "Bipartite.h"
#include "BIT.h"
#include "DynamicMod.h"
#include "Factorization.h"
#include "FFT.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "LazySegmentTree.h"
#include "Math.h"
#include "Matrix.h"
#include "MinCostFlowSolver.h"
#include "MinMax.h"
#include "Numbers.h"
#include "Polynomial.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "SlidingWindow.h"
#include "StringSeaching.h"
#include "SuffixArray.h"
#include "Tree.h"
#include "UnionFind.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>>(istream& ist, __int128& val) { LL tmp; ist >> tmp; val = tmp; return ist; }
ostream& operator<<(ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

string s;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int m = max(a, b);
	cout << (c + m - 1) / m << endl;
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val datA = for(i <- 1 to datN) yield (readLine.split(" ").map(_.toInt).head)

    val sb = datA.map{x => (false, x - 1)}.toVector
    def traverse(result: Int, pos: Int, sb: Vector[(Boolean, Int)]): Int = sb(pos) match {
      case (arrived, _) if (arrived) => -1
      case (_, next) if(next == 1) => result
      case (_, next) => traverse(result + 1, next, sb.updated(pos, (true, next)))
    }
    val ans = traverse(1, 0, sb)

    println(ans)
  }
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int u[112345];
int v[112345];
LL a[112345];
LL b[112345];
typedef vector<int> V;
typedef vector<V> VV;
vector<LL> latte(int s, int t, VV &g, LL *d) {
	using T = pair<LL,int>;
	priority_queue<T> que;
	int n = g.size();
	vector<LL> ret(n, 1e18);
	que.push({ 0ll,s }); ret[s] = 0;
	while (que.size()) {
		int now; LL c;
		tie(c, now) = que.top(); que.pop(); c = -c;
		for (auto &e : g[now]) {
			int nxt = u[e] ^ v[e] ^ now;
			LL nc = c + d[e];
			if (chmin(ret[nxt], nc)) {
				que.push({ -nc,nxt });
			}
		}
	}
	return ret;
}
int main() {
	int n, m, s, t;
	cin >> n >> m >> s >> t; s--; t--;
	VV g(n);
	for (int i : range(m)) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		u[i]--; v[i]--;
		g[u[i]].push_back(i);
		g[v[i]].push_back(i);
	}
	auto ei=latte(s, t, g, a);
	auto beet=latte(t, s, g, b);
	vector<LL> ret(n, 1e18);
	for (int i : range(n)) {
		ret[i] = ei[i] + beet[i];
	}

	for (int ri : range(1,n)) {
		const int i = n - 1 - ri;
		chmin(ret[i], ret[i + 1]);
	}
	const LL INF = 1e15;
	for (int i : range(n))cout <<INF- ret[i] << endl;
	return 0;
}


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

const int MAXN = 105;

int N;
double ai;

int main(){
	scanf("%d", &N);
	
	double s = 0.0;
	for(int i = 0; i < N; i++){
		scanf("%lf", &ai);
		s += 1.0 / ai;
	}
	printf("%.12f\n", 1.0 / s);
	
	return 0;
}


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

int main() {
	string T,W;
	int x;

	cin >> T;
	x = 0;

	while (1) {
		cin >> W;

		if (W == "END_OF_TEXT")
			break;

		for (int i = 0;i < W.length();i++)
			W[i] = tolower(W[i]);

		if (W == T)
			x++;
	}

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 1192
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  int sum = 0;
  for(int i = 0; i < S.length(); i++){
    sum = (sum + (S[i] - '0')) % 9;
  }
  if(sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3752
s = input()
 
for i in range(int(input())):
    cmd = input().split()
    a, b = int(cmd[1]), int(cmd[2])
 
    if cmd[0] == 'print':
        print(s[a:b+1])
    elif cmd[0] == 'reverse':
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif cmd[0] == 'replace':
        s = s[:a] + cmd[3] + s[b+1:]

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main() 
{
  int n;
  cin>>n;
  map<string,int>mp;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<(int)mp.size()<<endl;
  return 0;
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll a[200100];
ll ans=0;
map<ll,ll> m;

int main(){
	cin>>n;
	REP(i,n)
		cin>>a[i];
		
	if(a[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<n;i++){

		if(a[i]>a[i-1]+1){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++)
		m[i-a[i]]=a[i];
	for(auto it=m.begin();it!=m.end();it++){
		ans+=it->second;
	}
	cout<<ans<<endl;
	return 0;
}

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


ans = 10**12

for i in range(N):
    if i == 0:
        ans = min(ans, A[-1] - A[i])
    else:
        ans = min(ans, A[i-1] + (K - A[i]))

print(ans)


Measured memory_bytes: 26444
# -*- coding: utf-8 -*-

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def g(N: int) -> int:
    """
    1~Nの総和を求める.

    Args:\n
        N (int): 正整数

    Returns:\n
        int: 1~Nの総和
    """
    return int(N * (N + 1) / 2)


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 正整数（1 <= N <= 10^7）
    """
    # 求解処理
    ans = 0
    for n in range(1, N + 1):
        ans += n * g(N // n)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 9144