akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll gcd(ll a, ll b){
    if (b == 0) return a;
    return gcd(b, a%b);
}

const int N = 1e5;
ll a[N];
ll myleft[N];
ll myright[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    myleft[0] = a[0];
    for (int i = 1; i < n; i++){
        myleft[i] = gcd(myleft[i-1], a[i]);
    }

    myright[n-1] = a[n-1];
    for (int i = n-2; i >= 0; i--){
        myright[i] = gcd(myright[i+1], a[i]);
    }

    ll ans = max(myleft[n-2], myright[1]);
    for (int i = 1; i < n-1; i++){
        ans = max(ans, gcd(myleft[i-1], myright[i+1]));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5908
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
char s[20];
int main() {
	scanf("%s",&s[1]);
	const int n=strlen(&s[1]);
	int ans=0;
	for(register int l=1;l<=n;l++) {
		for(register int r=l;r<=n;r++) {
			for(register int i=l;i<=r;i++) {
				if(s[i]!='A'&&s[i]!='T'&&s[i]!='C'&&s[i]!='G') goto Next;
			}
			ans=std::max(ans,r-l+1);
			Next:;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
# ABC124B

n = int(input())
h = list(map(int, input().split()))
while True:
    removed = False
    for i in range(1, n):
        if i < len(h) and h[i-1] > h[i]:
            # print(f"removed {h[i]}")
            removed = True
            h.pop(i)
    if removed == False:
        break
print(len(h))


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

int main() {
    char str[102], sx[102];
    
    scanf("%s", str);
    
    for (int i = 0; i< strlen(str); ++i)
        sx[i] = 'x';
        
    sx[strlen(str)] = '\0';
        
    printf("%s\n", sx);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F_(i,a,b) for(int i=(a);i>=(b);--i)
#define G(i,u) for(int i=head[u];i;i=nxt[i])
 
typedef long long ll;
 
const int N = 100005;
 
template<typename T> inline T min(T& a, T b) {return a<b?a:a=b;}
 
int head[N], to[N<<1], nxt[N<<1], a[N], b[N], r[N], g[N], son[N], ecnt;
void add(int u, int v) { to[++ecnt] = v; nxt[ecnt] = head[u]; head[u] = ecnt; }
bool cmp(const int& x, const int& y) { return a[x] < a[y]; }
int find(int x) { return g[x] == x? x: g[x] = find(g[x]); }
ll f[N], sum[N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	F(i,1,n) {
		scanf("%d%d", &a[i], &b[i]);
		a[i] = std::max(a[i]-b[i],0); 
		r[i] = i;
	}
	F(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		add(u,v); add(v,u);
	}
	std::sort(r+1,r+n+1,cmp);
	F(i,1,n) {
		int x = r[i], tot = 0; g[x] = x; sum[x] = b[x];
		G(j,x) {
			int v = to[j], p = find(v);
			if(!p || p == x) continue;
			son[++tot] = p;
			sum[x] += sum[p];
			g[p] = x;
		}
		f[x] = a[x] + sum[x];
		F(j,1,tot) min(f[x],sum[x]-sum[son[j]]+std::max(f[son[j]],1ll*a[x]));
	}
	printf("%lld\n", f[r[n]]);
	return 0;
} 

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> a(n);
  ll sa=0;
  vector<ll> b(n);
  ll sb=0;
  rep(i,n) {
    cin>>a[i];
    sa+=a[i];
  }
  rep(i,n) {
    cin>>b[i];
    sb+=b[i];
  }
  if(sa<sb) {
    cout << -1 << endl;
    return 0;
  }
  ll s=0;
  int cnt=0;
  rep(i,n) {
    if(b[i]>a[i]) {
      s+=b[i]-a[i];
      cnt++;
    }
  }
  vector<ll> ds;
  rep(i,n) {
    if(a[i]>b[i]) {
      ds.push_back(a[i]-b[i]);
    }
  }
  sort(ds.begin(),ds.end());
  reverse(ds.begin(),ds.end());
  ll acc=0;
  int idx=0;
  while(acc<s) {
    cnt++;
    acc+=ds[idx];
    idx++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 2428
import sys

num_list = int(sys.stdin.readline())
lines = sys.stdin.readlines()
nums = map(int, lines)

max_diff = -sys.maxint - 1
min_val = nums.pop(0)
for num in nums :
    diff = num - min_val
    if diff > max_diff :
        max_diff = diff
    if num < min_val :
        min_val = num

print max_diff

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;

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

  printf("%d\n", a*a-b);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    ll n;
    cin>>n;
    map<ll,ll>mp;
    for(ll i=1;i<=n-1;i++){
        ll x;
        cin>>x;
        mp[x]++;
    }
    for(ll i=1;i<=n;i++)cout<<mp[i]<<endl;
    return 0;
}


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

namespace AOJ
{
    class Program
    {
        class Point
        {
            public double x, y;
            public readonly int i;

            public Point(double x, double y, int i)
            {
                this.x = x;
                this.y = y;
                this.i = i;
            }

            public override string ToString()
            {
                return i.ToString();
            }
        }
        static void Main(string[] args)
        {
            string line;
            while((line = Console.ReadLine()) != null)
            {
                if (line == "0") break;
                var n = int.Parse(line);
                var l = new List<Point>(n);
                for(int i = 0; i < n; i++)
                {
                    var s = Console.ReadLine().Split(',').Select(double.Parse).ToArray();
                    l.Add(new Point(s[0], s[1], i));
                }
                Point min = l.First(), @from = new Point(-10000, 0, -1), next;
                foreach(var point in l)
                {
                    if (point.y < min.y)
                        min = point;
                }
                next = min;
                var res = new HashSet<int>();
                do
                {
                    double min_angle = double.MaxValue;
                    Point min_point = @from;
                    foreach(var point in l)
                    {
                        if (@from == point || next == point) continue;
                        var x1 = next.x - @from.x;
                        var y1 = next.y - @from.y;
                        var x2 = point.x - next.x;
                        var y2 = point.y - next.y;
                        var a = Math.Atan2(x1 * y2 - x2 * y1, x1 * x2 + y1 * y2);
                        if (a < min_angle)
                        {
                            min_point = point;
                            min_angle = a;
                        }
                    }
                    @from = next;
                    next = min_point;
                    res.Add(@from.i);
                } while(min != next);
                Console.WriteLine(l.Count - res.Count);
            }
        }
    }
}

Measured memory_bytes: 6548
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
   
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int bit[200002], n0;
 
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i-=(i&(-i));
	}
	return s;
}
 
void add(int i){
	while(i<=n0){
		bit[i]+=1;
		i+=(i&(-i));
	}
}

int main()
{
	int n;
	cin>>n;
	n0=2*n+1;
	int a[100000];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	int m1=0, m2=1e9;
	while(m1!=m2){
		int m=(m1+m2)/2;
		int c[100001];
		for(int i=0; i<n; i++){
			if(a[i]<=m) c[i+1]=1;
			else c[i+1]=-1;
		}
		fill(bit, bit+2*n+2, 0);
		c[0]=0;
		ll ct=0;
		add(n+1);
		for(int i=1; i<=n; i++){
			c[i]=c[i]+c[i-1];
			ct+=((ll)sum(n+c[i]));
			add(n+1+c[i]);
		}
		if(ct>=((ll)n)*((ll)n+1)/2/2+1) m2=m;
		else m1=m+1;
	}
	cout<<m1<<endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	ans := false
	for N > 0 {
		if N%10 == 7 {
			ans = true
			break
		}
		N /= 10
	}
	if ans {
		out("Yes")
	} else {
		out("No")
	}
}


Measured memory_bytes: 1756
a, b, c, d = map(int, input().split())

b_count = a // d
if a % d != 0:
    b_count += 1

a_count = c // b
if c % b != 0:
    a_count += 1

if a_count <= b_count:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int d,n;
    cin>>d>>n;
    int p=1;
    while(d--)
        p*=100;
    if(n==100)
        n++;
    cout<<n*p;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;
const ll MOD = 1000000007;

int main(){
  int a, b;
  cin >> a >> b;
  cout << (a-1) * (b - 1) <<endl;
}

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

int main(void) {
	int A,B,C;
	cin >> A >> B >>C;

	cout << max(max(10*A+B+C,A+10*B+C),A+B+10*C) << endl;
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int m, f, r;
    
    while(scanf("%d %d %d", &m, &f, &r), m > -1 || f > -1 || r > -1){
        if(m < 0 || f < 0){
            putchar('F');
        }
        
        else if(m + f >= 80){
            putchar('A');
        }
        
        else if(m + f >= 65){
            putchar('B');
        }
        
        else if(m + f >= 50){
            putchar('C');
        }
        
        else if(m + f >= 30){
            
            if(r >= 50){
                putchar('C');
            }
            
            else {
                putchar('D');
            }
        }
        
        else {
            putchar('F');
        }
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2604
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define fr(i,b) for(ll i=0; i<=b; i++)
#define frr(i,b) for(ll i=0;i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j;
int main(){
  ll n; cin>>n;
  vl v(n);
  float mult=0;

  for(i=0;i<n;i++){
  	cin>>v[i];
  	float y=v[i];
  	float x=1/y;
  	mult =mult +x;
  }
 float ans=1/mult;
 cout<<setprecision(9)<<ans<<fixed<<endl;




    return 0;
}

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

using namespace std;


long long f(long long b, long long n) {
    long long ret = 0;
    while (n) {
        ret += n % b;
        n /= b;
    }
    return ret;
}

void run_case() {
//    n / b + (n % b) = s
//    let x = floor(n / b)
//    x + n - x * b = s
//    x - x * b = s - n
//    x * b - x = n - s
//    x ( b- 1 ) = n - s
//    b = (n-s) / x + 1

    long long n, s;
    cin >> n >> s;
    const int N = 1e6;
    if (n == s) {
        cout << n + 1 << endl;
        return;
    }

    if (s > n) {
        cout << -1 << endl;
        return;
    }

    for (int i = 2; i <= N; i++) {
        if (f(i, n) == s) {
            cout << i << endl;
            return;
        }
    }

    for (int x = N; x >= 1; x--) {
        long long b = (n - s) / x + 1;
        if (b >= 2 && (n - s) % x == 0 && f(b, n) == s) {
            cout << b << endl;
            return;
        }
    }

    cout << -1 << endl;

}


int main() {


    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)run_case();


    return 0;
}
 
 
 
 
 
 
 
 


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,k,a[1005],ans=0;
int main()
{
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	rep(i,k) ans+=a[i];
	re(ans)
	return 0;}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  string s,t;
  cin>>s>>t;
  int i,j,n=s.size(),m=t.size();
  int dp[n+1][m+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=m;j++)dp[i][j]=0;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  //cout<<dp[n][m];
  if(dp[n][m]==0)cout<<"";
  else
  {
    int ind= dp[n][m];
    char ans[ind+1];
    ans[ind]='\0';
    i=n,j=m;
    while(i>0&&j>0)
    {
      if(s[i-1]==t[j-1])
      {
        ans[ind-1]=s[i-1];
        ind--;
        i--;
        j--;
      }
      else if(dp[i-1][j]>dp[i][j-1])
      {
        i--;
      }
      else
        j--;
    }
    cout<<ans;
  }
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define MAX 1001001
#define NIL -1

/*
  疎なグラフ(連結成分が少ないグラフ)では、隣接行列を使うのはメモリefficientではない。
  ->隣接リストを用いて各ノードの関係を表す

  連結成分を求めるには、未訪問のノードを始点としてDFSを行う。
  この探索を行うごとに、各点に異なるIDを割り振ることで、どのグループに属するかを判定する。
*/

int n;
vector<int> G[MAX]; //頂点数がMAXまで格納できる隣接リスト(中身は配列)
int color[MAX]; //

void dfs_colorAssign(int start, int group_id) {
  stack<int> s;
  s.push(start);
  color[start] = group_id;

  while(!s.empty()) {
    int now = s.top(); s.pop();

    for (int i = 0; i < G[now].size(); i++) {
      int v = G[now][i];
      if (color[v] == NIL) {
        color[v] = group_id;
        s.push(v);
      }
    }
  }
}

void assign_color() {
  int id = 1;
  for (int i = 0; i < n; i++) color[i] = NIL; //color配列を初期化
  //未訪問の頂点はidがNILになる
  for (int i = 0; i < n; i++) {
    if (color[i] == NIL) dfs_colorAssign(i, id);
    id++;
  }
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t); // 互いの隣接リストに相手を追加
    G[t].push_back(s);
  }

  assign_color();

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 30104
S = input()
T = input()
s = [0]*26
t = [0]*26

dict = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7,
        'i':8, 'j':9, 'k':10, 'l':11, 'm':12, 'n':13, 'o':14,
        'p':15, 'q':16, 'r':17, 's':18, 't':19, 'u':20, 'v':21,
        'w':22, 'x':23, 'y':24, 'z':25}

for i in range(len(S)):
    s[dict[S[i]]] += 1
    t[dict[T[i]]] += 1
s.sort()
t.sort()
print('YNeos'[s!=t::2])


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');
            int h1 = int.Parse(inputStrArray[0]);
            int m1 = int.Parse(inputStrArray[1]);
            int h2 = int.Parse(inputStrArray[2]);
            int m2 = int.Parse(inputStrArray[3]);
            int k = int.Parse(inputStrArray[4]);

            int s = h1 * 60 + m1;
            int e = h2 * 60 + m2;
            int t = e - s - k;

            string result = (t<=0)?"0":t.ToString();

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }


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

long long N, M, ANS = 0;
vector<vector<long long> > V;
vector<pair<long long, long long> > Q;
map<pair<long long, long long>, long long> mp;
vector<long long> Euler;
vector<long long> S;
vector<vector<long long> > VE;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return C * C;
	}
	return A * Calc(A, B - 1);
}

void DFS(long long P, long long Q) {
	Euler.push_back(P);
	for (long long NP : V[P]) {
		if (NP != Q) {
			DFS(NP, P);
			Euler.push_back(P);
		}
	}
}

int main() {
	cin >> N;
	V.resize(N), S.assign(N, N * 3);
	for (int i = 0; i < N - 1; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back(B);
		V[B].push_back(A);
		mp[{A, B}] = i;
		mp[{B, A}] = i;
	}
	cin >> M;
	Q.resize(M);
	VE.resize(M);
	for (int i = 0; i < M; i++) cin >> Q[i].first >> Q[i].second, Q[i].first--, Q[i].second--;
	DFS(0, -1);
	for (long long i = 0; i < Euler.size(); i++) {
		S[Euler[i]] = min(S[Euler[i]], i);
	}
	for (int i = 0; i < M; i++) {
		long long X = Q[i].first, Y = Q[i].second;
		if (S[X] > S[Y]) swap(X, Y);
		for (int j = S[X]; j < S[Y]; j++) VE[i].push_back(mp[{Euler[j], Euler[j + 1]}]);
	}
	for (int i = 0; i < M; i++) {
		map<long long, bool> m;
		for (int j : VE[i]) m[j] = !m[j];
		VE[i].clear();
		for (int j = 0; j < N - 1; j++) {
			if (m[j]) VE[i].push_back(j);
		}
	}
	for (long long i = 0; i < (1 << M); i++) {
		long long COUNT = 0;
		long long I = i;
		vector<bool> B(N - 1, false);
		for (int j = 0; j < M; j++) {
			if (I % 2 == 1) {
				COUNT++;
				for (int k : VE[j]) B[k] = true;
			}
			I /= 2;
		}
		long long T = 0, F = 0;
		for (int i = 0; i < N - 1; i++) {
			if (B[i]) T++;
			else F++;
		}
		long long MUL = Calc(2, F);
		if (COUNT % 2 == 0) ANS += MUL;
		else ANS -= MUL;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
m = 1000
k = 0
for i in range(N-1):
  if A[i] < A[i+1]:
    k += m // A[i]
    m = m % A[i]
  elif A[i] > A[i+1]:
    m += k * A[i] 
    k = 0
m += k * A[N-1]
print(m)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi V(n);
  for(auto &a:V)cin>>a;
  ll ma=0;
  for(int i=0;i<=n;i++){
    if(i==n){
      if(k<i)continue;
      ll nokori=k-i;
      ll cost=0;
      priority_queue<ll,vi,greater<>>que;
      for(int j=0;j<n;j++){cost+=V[j];que.push(V[j]);}
      while(nokori>0&&!que.empty()&&que.top()<0){
	cost-=que.top();
	que.pop();
	nokori--;
      }
      // cout<<cost<<" "<<i<<" "<<j<<" "<<i+n-j<<endl;
      ma=max(ma,cost);
    }
    for(int j=n;j>=i;j--){
      if(k<i+(n-j))continue;
      ll cost=0;
      priority_queue<ll,vi,greater<>>que;
      for(int ii=0;ii<i;ii++){
	cost+=V[ii];
	que.push(V[ii]);
      }
      for(int ii=n-1;ii>=j;ii--){
	cost+=V[ii];
	que.push(V[ii]);
      }
      ll nokori=k-(i+n-j);
      while(nokori>0&&!que.empty()&&que.top()<0){
	cost-=que.top();
	que.pop();
	nokori--;
      }
      //cout<<cost<<" "<<i<<" "<<j<<" "<<i+n-j<<endl;
      ma=max(ma,cost);
    }
  }
  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>

using namespace std;

int n, k;
int a[5010];
int ans;

const long long MOD = 1e9 + 239;
long long dp[15111];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        if (b >= k)
        {
            n--;
            i--;
            continue;
        }
        a[i] = b;
    }
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 3 * k; j >= a[i]; j--)
        {
            dp[j] = (dp[j] + dp[j - a[i]]) % MOD;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i]; j <= 3 * k; j++)
        {
            dp[j] = (dp[j] + MOD - dp[j - a[i]]) % MOD;
        }
        int t = 0;
        for (int j = k - a[i]; j < k; j++) if (dp[j] != 0) t = 1;
        //cout << k - a[i] << " " << k << " " << t << endl;
        //for (int j = 0; j < 2 * k; j++) cout << dp[j] << " ";
        //cout << endl;
        if (t == 0)
            ans++;
        for (int j = 3 * k; j >= a[i]; j--)
        {
            dp[j] = (dp[j] + dp[j - a[i]]) % MOD;
        }
    }
    cout << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

const int MAX_SIZE = 52;

int LCS(const char* a, const char* b){
    int n = 0, m = 0;
    vector<int> x,y;
    for(;a[n] != '\0';n++){
        int s = a[n]-'a';
        if(s < 0){
            s = a[n]-'A'+26;
        }
        x.pb(s);
    }
    for(;b[m] != '\0';m++){
        int s = b[m]-'a';
        if(s < 0){
            s = b[m]-'A'+26;
        }
        y.pb(s);
    }
    vector<vector<int> > vec(MAX_SIZE);
    for(int j = m-1; j >= 0; --j){
        vec[y[j]].push_back(j);
    }
    vector<int> xs(n+1, INF);
    xs[0] = -INF;
    vector<P> nx(n+1,P(-INF,-INF));
    rep(i,n){
        vector<int>& ys = vec[x[i]];
        rep(j,(int)ys.size()){
            int k = lower_bound(xs.begin(),xs.end(),ys[j]) - xs.begin();
            xs[k] = ys[j];
            nx[k] = P(y[ys[j]], k-1);
        }
    }
    return lower_bound(xs.begin(),xs.end(),INF-1) - xs.begin() - 1;
}


int main()
{
    int q;
    scanf("%d",&q);
    rep(i,q){
        char x[1000], y[1000];
        scanf("%s%s",x,y);
        cout << LCS(x,y) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3256
N = int(input())

p = list(map(int,input().split()))

a = [0] * N
b = [0] * N

for i in range(N):

    b[i] = (N-i) * N
    a[i] = (i + 1) * N

for i in range(N):
    b[p[i]-1] += i

print (" ".join(map(str,a)))
print (" ".join(map(str,b)))


Measured memory_bytes: 7232
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 1000000000

int main(){
    int N, K;
    vector<int> h;

    cin >> N >> K;

    for (int i = 0; i < N; i++){
        int temp;
        cin >> temp;
        h.push_back(temp);
    }
    sort(h.begin(), h.end());
    int dif = MAX;
    for (int ii = 0; ii < N - K + 1; ii++){
        int tempDif = h[ii + K - 1] - h[ii];
        if (tempDif == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (dif > tempDif){
            dif = tempDif;
        }
    }

    cout << dif << endl;
    return 0;
}

Measured memory_bytes: 892
import sys, collections
input = sys.stdin.readline

n, q = map(int, input().split())
graph = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
add = [0 for i in range(n + 1)]
for i in range(q):
    p, x = map(int, input().split())
    add[p] += x
flag = [False for i in range(n + 1)]
check = collections.deque([1])
while check:
    test = check.popleft()
    flag[test] = True
    num_list = graph[test]
    for i in num_list:
        if flag[i] == True:
            pass
        else:
            add[i] += add[test]
            check.append(i)
for i in range(n):
    print(add[i + 1], end = " ")
print()

Measured memory_bytes: 123748
#include <bits/stdc++.h> 
using namespace std;
 
int main(){
  
  int n;
  cin>>n;
  
  int b=n%1000;
  
  if(b==0){
    cout<<0<<endl;
  }
  else{
    cout<<1000-b<<endl;
  }
  
  
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  double d1 = 0.0000000, d2 = 0.0000000, d3 = 0.0000000, dul = 0.0000000;
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < n; i++) {
    cin >> y[i];
    double yoso = abs((double)x[i] - (double)y[i]);
    d1 += yoso;
    d2 += yoso * yoso;
    d3 += yoso * yoso * yoso;
    dul = max(dul, yoso);
  }
  cout << fixed << setprecision(7);
  cout << d1 << "\n";
  cout << sqrt(d2) << "\n";
  cout << cbrt(d3) << "\n";//
  cout << dul << "\n";
}


Measured memory_bytes: 3448
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,nxt[100005];
char s[100005];
ll f[100005],ans;
int main()
{
	scanf("%s",s+1);
	n=(int)strlen(s+1);
	nxt[n]=n+1;
	for(int i=n;i>=1;i--)nxt[i-1]=s[i]==s[i+1]?i+1:nxt[i];
	f[0]=1;
	for(int i=0;i<=n;i++)
	{
		f[i]%=MOD;
		f[i+1]+=f[i];
		f[nxt[i]]+=f[i];
	}
	int now=0;
	bool flag=0;
	for(int i=n;i>=1;i--)
	{
		flag|=s[i]==s[i+1];
		if(now==0)ans+=f[i];
		now=(now+s[i]-'a'+1)%3;
	}
	if(!flag)printf("1\n");
	else printf("%lld\n",ans%MOD);
	return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin >> n;
	vector <ll> nums = vector<ll>(n);
	
	for(int i = 0; i < n; i++)
		cin >> nums[i];
		
	int maximum = INT_MIN;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++)
		{
			if(i != j)
			{
				ll dif = nums[i]-nums[j];
			if(maximum < dif)
				maximum = dif;
			}
			
		}
	}
	cout << maximum << '\n';
		
	return 0;
}


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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << '\n';

    return 0;
}


Measured memory_bytes: 256
def eratosthenes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, int(n**0.5) + 1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False

    return is_prime


q = int(input())

p = eratosthenes(10 ** 5)
l = [0] * 10 ** 5
for i in range(3, 10 ** 5, 2):
    if p[i] and p[(i+1)//2]:
        l[i] = 1

sum_l = [0]
for v in l[1:]:
    sum_l.append(sum_l[-1] + v)

res = []
for _ in range(q):
    l, r = map(int, input().split())
    res.append(sum_l[r] - sum_l[l-1])

for v in res:
    print(v)

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

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> vec(m);
    ll task = 0;
    for(int i=0;i<m;i++){
        int n;
        cin >> n;
        task += n;
    }
    if(n<task) cout << -1 << endl;
    else cout << n-task << endl;
}

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

using namespace std;
using ll = long long;

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

int dp[1005][20005];

int main() {
  int h, n;
  cin >> h >> n;
  int a[n + 1], b[n + 1];
  rep(i, n) cin >> a[i + 1] >> b[i + 1];

  int mx = 0;
  rep(i, n) mx = max(mx, a[i + 1]);

  const int INF = 1001001001;
  rep(i, 20005) dp[0][i] = INF;
  dp[0][0] = 0;

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= h + mx; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (j - a[i] >= 0) {
        dp[i][j] = min(dp[i][j],
                       min(dp[i][j - a[i]] + b[i], dp[i - 1][j - a[i]] + b[i]));
      }
    }
  }

  int ans = INF;
  rep(i, mx) {
    if (dp[n][h + i]) ans = min(ans, dp[n][h + i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000


int main() {

  char C;

  cin >> C;
  C++;

  cout << C << endl;



 
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def fs(n):
    f = Counter()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        if i > n:
            break
        while n % i == 0:
            f[i] += 1
            n /= i
    if int(n) != 1:
        f[int(n)] = 1
    return f

@mt
def slv(N, M):
    ans = 1
    for m in range(1, math.ceil(math.sqrt(M))+1):
        if M % m != 0:
            continue
        
        if  N*m <= M:
            ans = max(ans, m)
        if  N*(M//m) <= M:
            ans = max(ans, M//m)

    return ans


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()




Measured memory_bytes: 6604
#include <iostream>

using namespace std;

int main() {
  float a, b;
  cin >> a >> b;
  a = (a + b) / 2;
  int c = a;
  if (a - c >= 0.5) cout << c + 1 << '\n';
  else cout << c << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
    }
    else{
        n /= 2;
        ll x = n,ans = 0;
        while(x){
            ans += x / 5;
            x /= 5;
        }
        cout << ans << endl;
    }
}

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

import static java.lang.Integer.parseInt;

/**
 * Koto Municipal Subway
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int D, E;
			D = parseInt(line.substring(0, line.indexOf(' ')));
			E = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((D | E) == 0) break;

			double min = Double.POSITIVE_INFINITY;
			for (int x = 0; x <= D / 2; x++) {
				int y = D - x;
				min = Math.min(min, Math.abs(Math.sqrt(x * x + y * y) - E));
			}
			System.out.println(min);
		} //end while
	} //end main
}

Measured memory_bytes: 24372
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n , p / 2);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret ;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	
	vll A(N);
	rep(i, 0, N) {
		std::cin >> A[i];
	}

	// N=2
	if (N == 2) {
		std::cout << max(A[0], A[1]) << endl;
		return 0;
	}

	//N>2
	ll all_gcd = A[0];
	ll ans = 0;
	rep(i, 0, 3) {
		all_gcd = gcd(all_gcd, A[i]);
		ans = max(ans,gcd(A[(i + 1) % 3],A[(i+2)%3]));
	}

	rep(i, 3, N) {
		ll tmp_gcd = gcd(ans, A[i]);
		if (tmp_gcd < all_gcd) {
			ans = all_gcd;
		}
		else {
			ans = tmp_gcd;
		}
		all_gcd = gcd(all_gcd, A[i]);
	}
	std::cout << ans << endl;

	return 0;
}


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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b){
  if (a <= b) return false;
  a = b;
  return true;
}

template<class T> inline bool chmax(T& a, T b) {
  if (a >= b) return false;
  a = b;
  return true;
}

void solve(void){
  ll n, k; cin >> n >> k;
  vector<ll> h(n, 0);
  rep(n, i) cin >> h[i];

  vector<ll> dp(n+1000, INF);
  dp[0] = 0;

  rep(n, i) {
    for(ll j = 1; j <= k; ++j) chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
  }

  cout << dp[n-1] << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

using namespace std;

const int N = 1000000000;

const int N1 = N-1;
 
signed main()
{
    fast;
    int n,k,s;
    cin>>n>>k>>s;

    for ( int i = 0 ; i < k ; i++ )
    {
        cout<<s<<" ";
    }

    if ( s == N )
    {
        for ( int i = 0 ; i < n-k ; i++ )
        {
            cout<<1<<" ";
        }
    }
    else
    {
        for ( int i = 0 ; i < n-k ; i++ )
        {
            cout<<N<<" ";
        }
    }
    
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

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

    bool f = false;
    for (int i = 0; i <= n; i += 4) {
        if ((n - i) % 7 == 0) {
            f = true;
            break;
        }
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vi= vector<int>;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvi= vector<vector<int>>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N;
    cin >> N;
    vector<ll> B(N);
    vector<pll> A(N);
    REP(i,N){
        cin >> A[i].fi >> A[i].se;
        A[i].fi--;
        A[i].se--;
        B[A[i].fi] = A[i].se;
    }
    vl X(N);
    REP(i,N){
        X[A[i].fi] = i;
    }
    vl maxes(N);
    vl mines(N);
    maxes[N-1] = B[N-1];
    mines[0] = B[0];
    REPS(i,N-1){
        maxes[N-i-1] = max(B[N-i-1],maxes[N-i]);
        mines[i] = min(B[i],mines[i-1]);
    }
    vl rui(N);
    ll cons = 1;
    REP(i,N-1){
        if(mines[i] > maxes[i+1]){
            rui[i+1] += -cons;
            rui[i-cons+1] += cons;
            cons = 1;
        }else{
            cons++;
        }
    }
    rui[N-cons]+=cons;
    ll sum = 0;
    vl ans(N);
    REP(i,N){
        ans[X[i]] = (sum += rui[i]);
    }
    REP(i,N)cout << ans[i] << "\n";
}

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

int main() {
  double n,m;
  cin>>n>>m;
  int kaisuu=pow(2,m);
  int souwa=100*(n-m)*pow(2,m)+1900*m*pow(2,m);  
  cout<<souwa<<endl;
  return 0;
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    
    for(int i=1; i<=3; i++){
        if(a*b*i%2 == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" <<endl;
}



Measured memory_bytes: 3568
MOD = 10**9+7
    
def comb(a:int, b:int):
    if b > a-b: return comb(a, a-b)
    mul = 1
    div = 1
    for i in range(b):
        mul *= a-i
        div *= i+1
        mul %= MOD
        div %= MOD
        
    ret = mul * pow(div, MOD-2, MOD)
    return ret

if __name__ == '__main__':
    N,M = map(int, input().split())
    ans = 1
    
    #  素因数分解
    i=2
    nokori = M
    while i*i <= nokori:
        if nokori%i==0:
            cnt = 0
            while nokori%i==0:
                cnt += 1
                nokori //= i
            ans *= comb(N+cnt-1, N-1)
            ans %= MOD
        i += 1
            
    if nokori != 1:
        ans *= comb(N+1-1, N-1)
        ans %= MOD
        
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int X,Y,Z,K; cin >> X>> Y >> Z >> K;
  vll A(X), B(Y), C(Z);
  rep(i,X)cin>>A[i];
  rep(i,Y)cin>>B[i];
  rep(i,Z)cin>>C[i];

  vll T;
  rep(i,X)rep(j,Y)T.push_back(A[i]+B[j]);
  sort(T.rbegin(), T.rend());
  vll T2(K);
  rep(i,min(K, (int)T.size())) T2[i] = T[i];
  vll T3;
  rep(i,T2.size())rep(j,Z)T3.push_back(T2[i]+C[j]);
  sort(T3.rbegin(), T3.rend());
  rep(i,K) printf("%lld\n",T3[i]);
  return 0;
}

Measured memory_bytes: 44124
import collections
import sys

N, x = map(int, input().split())
A_lis = list(map(int, input().split()))
A_q = collections.deque(A_lis)

sys.setrecursionlimit(10 ** 9)

con = 0
tmp1 = A_q.popleft()
for i in range(N-1):
    tmp2 = A_q.popleft()
    if tmp1 + tmp2 > x:
        con += int((tmp1 + tmp2) - x)
        tmp1 = max(0, x - tmp1)
    else:
        tmp1 = tmp2

print(con)


Measured memory_bytes: 14516
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = input()
t = input()

flag = True
hmax = h
wmax = w
hmin = 1
wmin = 1

for i in range(n, 0, -1):
    if t[i - 1] == "U":
        hmax = min(hmax + 1, h)
    elif t[i - 1] == "D":
        hmin = max(hmin - 1, 1)
    elif t[i - 1] == "L":
        wmax = min(wmax + 1, w)
    elif t[i - 1] == "R":
        wmin = max(wmin - 1, 1)

    if s[i - 1] == "U":
        hmin += 1
    elif s[i - 1] == "D":
        hmax -= 1
    elif s[i - 1] == "L":
        wmin += 1
    elif s[i - 1] == "R":
        wmax -= 1

    if hmax < hmin or wmax < wmin:
        flag = False
        break

if not hmin <= sr <= hmax or not wmin <= sc <= wmax:
    flag = False

print("YES" if flag else "NO")

Measured memory_bytes: 3788
using System.Text;
public partial class IntroductionToProgramming{
	public static void Main(){
		int n = int.Parse(System.Console.ReadLine());

		StringBuilder sb = new StringBuilder();

		for (int i = 1; i <= n; i++)
		{
			if (i % 3 == 0)
			{
				sb.Append(" " + i.ToString());
			}
			else if (i.ToString().IndexOf('3') != -1)
			{
				sb.Append(" " + i.ToString());
			}
		}

		System.Console.WriteLine(sb.ToString());
	}
}

Measured memory_bytes: 17844