akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	g = zeros(Int,n,n)
	d = 10000000*ones(Int,n,n)
	for i in 1:n
		d[i,i] = 0
	end
	x = 0
	for i in 1:m
		a,b,c = readline() |> split |> parseMap
		g[a,b] = c
		g[b,a] = c
		d[a,b] = c
		d[b,a] = c
	end
	for k in 1:n
		for i in 1:n
			for j in 1:n
				d[i,j] = min(d[i,j],d[i,k]+d[k,j])
			end
		end
	end
	for i in 1:n-1
		for j in i+1:n
			if g[i,j] > 0
				f = 0
				for s in 1:n
					if d[s,i] + g[i,j] == d[s,j]
						f = 1
						break
					end
				end
				if f == 0
					x += 1
				end
			end
		end
	end
	println(x)
end

main()

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

const int N = 100005;

int n, m, l, r, c;
vector<pair<int, int>> ve[N];
vector<long long> eve[N];
multiset<long long> se = {0};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    while (m--) {
        cin >> l >> r >> c;
        ve[l].push_back({r, c});
    }
    eve[2].push_back({0});
    for (int i = 1; i <= n; i++) {
        for (long long &v : eve[i]) {
            se.erase(se.find(v));
        }
        if (se.empty()) {
            return cout << -1, 0;
        }
        long long tmp = *se.begin();
        if (i == n) {
            return cout << tmp, 0;
        }
        for (pair<int, int> &v : ve[i]) {
            se.insert(tmp + v.second);
            eve[v.first + 1].push_back(tmp + v.second);
        }
    }
}


Measured memory_bytes: 11008
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);

		for( ; ; ){
		int x = sc.nextInt();
		int y = sc.nextInt();
	    if(x==0 && y==0) {
	    	break;
	        }
		
		if(x<y)
            System.out.println(x+" "+y);
	    else
	        System.out.println(y+" "+x);
        }

        
        
    }
}



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

int main(){
    string S,T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0;i < 3;i++){
        if(S[i] == T[i]){
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = getInt()
    val input = getInts()

    var out = 0
    (0 until n).forEach { aa->
        val a = input[aa]
        (aa + 1 until n).forEach { bb ->
            val b = input[bb]
            (bb + 1 until n).forEach { cc ->
                val c = input[cc]
                if (a != b && a != c && b != c) {
                    val (x, y, z)= arrayOf(a,b,c).sorted()
                    if (x + y > z) out++
                }
            }
        }
    }
    println(out)
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 56104
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long

/*
3 100
1 2
2 3
*/
vector<vector<int> >adjlist;
vector<int>dp2asroot;
vector<int>dp1nonroot;
int m;

void solve1(int node,int par){
    int sz = adjlist[node].size();
    ll w=1;
    for(int i=0;i<sz;i++){
        int u = adjlist[node][i];
        if(u!=par){
            solve1(u,node);
            w *= ((ll)dp1nonroot[u]+1)%m;
            w %=m;
        }
    }
    dp1nonroot[node] = w;
}
void solve2(int node,int par_val,int par){
    int sz = adjlist[node].size();
    ll w=1;
    w = ((ll)dp1nonroot[node]*((1+par_val)%m))%m;
    dp2asroot[node] = w;
    vector<int>chld;
    for(int i=0;i<sz;i++){
        if(adjlist[node][i]==par){
            continue;
        }
        chld.push_back(adjlist[node][i]);
    }
    sz = chld.size();
    vector<int>prefix(sz,1),suffix(sz,1);
    for(int i=1;i<sz;i++){
        prefix[i] = ((ll)prefix[i-1]*((dp1nonroot[chld[i-1]]+1)%m))%m;
    }
    for(int i=sz-2;i>=0;i--){
        suffix[i] = ((ll)suffix[i+1]*((dp1nonroot[chld[i+1]]+1)%m))%m;
    }

    for(int i=0;i<sz;i++){
        int u = chld[i];
        int pv = ((((ll)prefix[i]*suffix[i])%m)*((par_val +1)%m))%m;
        solve2(u,pv,node);
    }
    return;
}

void solve(){
  int n;cin>>n>>m;
  adjlist.resize(n);
  dp1nonroot.resize(n,-1);
  dp2asroot.resize(n,-1);
  for(int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;
    adjlist[a-1].push_back(b-1);
    adjlist[b-1].push_back(a-1);
  }
  solve1(0,-1);
  solve2(0,0,-1);
    for(int i=0;i<n;i++){
        cout<< dp2asroot[i]<<"\n";
    }
}

int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
int n, w[1500], c[1500], r[1500], dp[1500][1500];
int main() {
    cin >> n; for (int i = 1; i <= n; i++) { cin >> c[i] >> w[i]; r[i] = w[i]; }
    for (int i = 1; i <= n; i++)r[i] += r[i - 1];
    for (int i = 1; i <= n; i++) { dp[i][i] = 1; }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= n; j++) {
            int L = j, R = j + i; if (R > n)continue;
            if (dp[L][R] == 0)continue;
            int WA = r[R] - r[L - 1];
            if (L >= 2 && c[L - 1] >= WA) { dp[L - 1][R] = 1; }
            if (R < n && c[R + 1] >= WA) { dp[L][R + 1] = 1; }
        }
    }
    int cnt = 0, p = 1, q = 1;
    while (p <= n) {
        while (dp[p][q] == 1) { q++; }
        cnt++; p = q;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 7448
# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
INF=10**15
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in range(n):
    b[i+1]=b[i]+a[i]
dp=[[-1]*n for i in range(n)]
for i in range(n):
    dp[i][i]=0
def memo(i,j):
    if dp[i][j]>=0:
        return dp[i][j]
    ans=INF
    for k in range(i,j):
        ans=min(ans,memo(i,k)+memo(k+1,j))
    dp[i][j]=ans+b[j+1]-b[i]
    return dp[i][j]
print(memo(0,n-1))

Measured memory_bytes: 43244
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

mi = 9
ar = a % 10
if ar > 0 and ar < mi:
  mi = ar
br = b % 10
if br > 0 and br < mi:
  mi = br
cr = c % 10
if cr > 0 and cr < mi:
  mi = cr
dr = d % 10
if dr > 0 and dr < mi:
  mi = dr
er = e % 10
if er > 0 and er < mi:
  mi = er

li = [a,b,c,d,e]
su = 0
fl = 0
for i in li:
  if i%10==mi and fl == 0:
#    print("{} += {}".format(su,i))
    su = su + i
    fl = 1
  else:
#    print("{} += {}".format(su,i//10*10+10))
    if i%10 == 0:
      su = su+i
    else:
      su = su + i//10*10+10
print(su)


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

int main() {
  int n, p;
  string s;
  vector<tuple<string, int, int>> vec;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> s >> p;
    p = 100-p;
    vec.push_back(make_tuple(s, p, i));
  }
  sort(vec.begin(), vec.end());
  
  int a;
  for(int i = 0; i < n; i++) {
    tie(ignore, ignore, a) = vec.at(i);
    cout << a+1 << endl;
  }
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!{
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h]
    }
    let mut kuro_num = 0;
    let mut retu = vec![0; w];
    let mut gyo = vec![0; h];

    for g in 0..h {
        for r in 0..w {
            if c[g][r] == '#' {
                kuro_num += 1;
                retu[r] += 1;
                gyo[g] += 1;
            }
        }
    }

    let d_kuro = kuro_num - k;

    let mut vbitw = Vec::new();
    {
        let mut bitw = 0;
        loop {
            let mut bits = Vec::new();
            if bitw >= (1 << w) {break;}
            for i in 0..w {
                if bitw & (1 << i) > 0 {
                    bits.push(i);
                }
            }
            vbitw.push(bits);
            bitw += 1;
        }
    }
    let mut vbith = Vec::new();
    {
        let mut bith = 0;
        loop {
            let mut bits = Vec::new();
            if bith >= (1 << h) {break;}
            for i in 0..h {
                if bith & (1 << i) > 0 {
                    bits.push(i);
                }
            }
            vbith.push(bits);
            bith += 1;
        }
    }

    let mut ans = 0;
    for ws in &vbitw {
        for hs in &vbith {
            let mut sum = 0;
            for w in ws {
                sum += retu[*w];
            }
            for h in hs {
                sum += gyo[*h];
            }
            for w in ws {
                for h in hs {
                    if c[*h][*w] == '#'
                    {
                        sum -= 1;
                    }
                }
            }
            if d_kuro == sum {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n;cin>>n;
  string s;cin>>s;
  if(n%2==1 || s.substr(0, n/2)!=s.substr(n/2, n/2)){
    cout << "No" << endl;
  } else cout << "Yes" << endl;


  return 0;
}

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

using namespace std;

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

	
	long long int x = min(B-1, N);
    cout << floor(A*x/B) - A*floor(x/B) << endl;

	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int a,b,c,d,e,x,y,z,h,j,k;
    cin >> a >> b >> c >> d >> e;
x=abs(a);
y=x*c;
h=b-a;
j=h*e;
z=b*e;

if(a<0){
    k=y+d+z;
    cout << k << endl;
}
else if(a>0){
    cout << j << endl;
}
}


Measured memory_bytes: 3092
import heapq
import math
[N, M] = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    A[i] = -A[i]
heapq.heapify(A)
for i in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, x/2)
sum = 0
for i in range(N):
    sum += math.floor(abs(A[i]))
print(sum)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      if(s[i]=='C'&&s[j]=='F'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
# coding:utf-8
 
x, y, z = list(map(int, input().split()))
if x == 5 and y == 7 and z == 5:
  print("YES")
elif x == 7 and y == 5 and z == 5:
  print("YES")
elif x == 5 and y == 5 and z == 7:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{
    int N, sum = 0;
    cin >> N;
    vec A(2 * N);
    rep(i, 2 * N)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    rep(i, 2 * N)
    {
        if (i % 2 == 0)
        {
            sum += A[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s.at(i);
  }
  string ans;
  for(char c='a';c<='z';c++){
    int a=1e6;
    rep(i,n){
      int mini=0;
      rep(j,s.at(i).size()){
        if(s.at(i).at(j)==c){
          mini++;
        }
      }
      a=min(a,mini);
    }
    rep(k,a){
      ans+=c;
    }
  }
  cout << ans;
}
        

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(), b = s.nextInt();
        int sum = a + b, c = a - b, d = a * b;
        int max = sum;
        if(sum < c){
            if(c < d){
                max = d;
            } else{
                max = c;
            }
        } else if(sum < d){
            max = d;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
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);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int n=s.size();
    rep(i,0,n)if(s[i]=='?')s[i]='D';
    cout<<s<<endl;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define MAXN 200005
using namespace std;
using namespace __gnu_pbds;  

int k,n;
int arr[MAXN];

void solve()
{
	cin>>k>>n;
	for(int i=0;i<n;i++) cin>>arr[i];
	int maxx=INT_MIN;
	for(int i=1;i<n;i++)
	{
		maxx=max(maxx,arr[i]-arr[i-1]);
	}
	int p=k-arr[n-1]+arr[0];
	maxx=max(maxx,p);
	cout<<k-maxx<<endl;
}

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL datas[405];
LL pref[405];
LL memo[405][405];
int n;
const LL INF=1e17;
LL solve(int L, int R)
{
	if(L==R) return 0;
	if(memo[L][R]!=-1) return memo[L][R];
	LL ret=INF;
	for(int z=L;z<R;z++)
	{
		solve(L+1, R);
	}
	for(int z=R;z>L;z--)
	{
		solve(L, R-1);
	}
	LL total=pref[R]-pref[L-1];
	LL now=0;
	for(int z=L;z<R;z++)
	{
		ret=min(ret, now+solve(L, z)+solve(z+1, R)+(total-now));
	}
	return memo[L][R]=ret;
}

int main()
{
	scanf("%d", &n);
	for(int a=1;a<=n;a++)
	{
		scanf("%lld", &datas[a]);
		pref[a]=datas[a]+pref[a-1];
	}
	memset(memo, -1, sizeof(memo));
	printf("%lld\n", solve(1, n));
	return 0;
}

Measured memory_bytes: 1536
N = int(input())
Ls = sorted(list(map(int, input().split())),reverse=True) #ソートしておく
r = list(reversed(Ls))
from bisect import bisect_right
ans = 0
for i in range(N):
    for j in range(i+1,N):
        x = Ls[i] - Ls[j]
        ind = bisect_right(r,x)
        ans += max(0,N-ind-j-1)
print(ans)

Measured memory_bytes: 44252
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }else if(A >= 6){
        cout << B / 2 << endl;
    }else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    way = [[] for i in range(n+1)]
    for i in range(n-1):
        a,b = map(int,ipt().split())
        way[a].append(b)
        way[b].append(a)

    d = [-1]*(n+1)
    d[1] = 0
    q = [1]
    while q:
        qi = q.pop()
        dqi = d[qi]
        for i in way[qi]:
            if d[i] == -1:
                d[i] = dqi+1
                q.append(i)
    mi = -1
    ma = 0
    for i,di in enumerate(d):
        if ma < di:
            mi = i
            ma = di

    d = [-1]*(n+1)
    d[mi] = 0
    q = [mi]
    while q:
        qi = q.pop()
        dqi = d[qi]
        for i in way[qi]:
            if d[i] == -1:
                d[i] = dqi+1
                q.append(i)
    mi = -1
    ma = 0
    for i,di in enumerate(d):
        if ma < di:
            mi = i
            ma = di
    ma += 1
    if ma%3 == 2:
        print("Second")
    else:
        print("First")
    return None

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_a() {
	ll n, m;
	//ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	ll x[4], y[4];
	cin >> x[0] >> y[0] >> x[1] >> y[1];

	ll vx, vy;
	vx = x[1] - x[0];
	vy = y[1] - y[0];

	x[2] = x[1] - vy;
	y[2] = y[1] + vx;

	x[3] = x[2] - vx;
	y[3] = y[2] - vy;


	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int N = S.size();
  
  //string T = S;
  //reverse(T.begin(),T.end());
  
  bool Q = true;
  
  for(int i=0; i<N; i++){
    if(S.at(i) != S.at(N-1-i)){
      Q = false;
      break;
    }
  }
  
  int a = (N-1)/2;
  int b = (N+3)/2;
  
  if(Q){
    for(int i=0; i<a; i++){
      if(S.at(i) != S.at((a-1-i))){
        Q = false;
        break;
      }
    }
  }
  
  if(Q){
    for(int i=b-1; i<N; i++){
      if(S.at(i) != S.at(N+b-2-i)){
        Q = false;
        break;
      }
    }
  }
  
  if(Q){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, m, num[300007], sum[300007], f[300007], g[300007], h[300007], tmp[300007], st[300007], tp, inf = 1e18;
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
double slope(int a, int b, int f[])
{
	int x = f[a] + sum[a] + (a * a - a) / 2, y = f[b] + sum[b] + (b * b - b) / 2;
	return ((double)(y - x)) / (b - a);
}
int dp(int f[])
{
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + num[i];
	st[0] = tp = 0;
	for (int i = 1; i <= n; i++)
	{
		while (tp && slope(st[tp - 1], st[tp], f) <= i)tp--;
		f[i] = max(f[i - 1], f[st[tp]] + (i - st[tp]) * (i - st[tp] + 1) / 2 - (sum[i] - sum[st[tp]]));
		while (tp && slope(st[tp - 1], st[tp], f) <= slope(st[tp - 1], i, f))tp--;
		st[++tp] = i;
	}
	return 0;
}
int solve(int l, int r)
{
	if (l == r) { h[l] = max(h[l], f[l - 1] + g[l + 1] + 1 - num[l]); return 0; }
	int mid = (l + r) / 2;
	solve(l, mid);
	solve(mid + 1, r);
	sum[l - 1] = 0;
	for (int i = l; i <= r; i++)
		sum[i] = sum[i - 1] + num[i];
	st[0] = l - 1;
	tp = 0;
	for (int i = l; i <= mid; i++)
	{
		while (tp && slope(st[tp - 1], st[tp], f) <= slope(st[tp - 1], i, f))tp--;
		st[++tp] = i;
	}
	for (int i = mid + 1; i <= r; i++)
	{
		while (tp && slope(st[tp - 1], st[tp], f) <= i)tp--;
		tmp[i] = f[st[tp]] + (i - st[tp]) * (i - st[tp] + 1) / 2 - (sum[i] - sum[st[tp]]) + g[i + 1];
	}
	int ans = -inf;
	for (int i = r; i >= mid + 1; i--)
		ans = max(ans, tmp[i]), h[i] = max(h[i], ans);

	sum[r + 1] = 0;
	for (int i = r; i >= l; i--)
		sum[i] = sum[i + 1] + num[i];
	st[0] = r + 1;
	tp = 0;
	for (int i = r; i >= mid + 1; i--)
	{
		while (tp && slope(st[tp - 1], st[tp], g) >= slope(st[tp - 1], i, g))tp--;
		st[++tp] = i;
	}
	for (int i = mid; i >= l; i--)
	{
		while (tp && slope(st[tp - 1], st[tp], g) >= i)tp--;
		tmp[i] = g[st[tp]] + (st[tp] - i) * (st[tp] - i + 1) / 2 - (sum[i] - sum[st[tp]]) + f[i - 1];
	}
	ans = -inf;
	for (int i = l; i <= mid; i++)
		ans = max(ans, tmp[i]), h[i] = max(h[i], ans);
	return 0;
}
signed main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		num[i] = read(), h[i] = -inf;
	dp(f);
	reverse(num + 1, num + n + 1);
	dp(g);
	reverse(num + 1, num + n + 1);
	reverse(g + 1, g + n + 1);
	solve(1, n);
	m = read();
	for (int i = 1; i <= m; i++)
	{
		int a = read(), b = read();
		//cout << f[a - 1] + g[a + 1] << ' ' << h[a] + num[a] - b << endl << endl;;
		printf("%lld\n", max(f[a - 1] + g[a + 1], h[a] + num[a] - b));
	}
	return 0;
}

Measured memory_bytes: 17024
N, M = gets.split.map(&:to_i)
divisors = []
(1..(Math.sqrt(M).to_i)).each do |n|
  next unless M % n == 0
  divisors.push(n)
  divisors.push(M / n)
end
sorted = divisors.sort_by { |n| -n }
sorted.each do |d|
  if M / d >= N
    puts d
    exit 0
  end
end


Measured memory_bytes: 3836
import numpy as np
# 締切が早いものから処理
N = int(input())
AB = np.array([[int(x) for x in input().split()] for _ in range(N)])
A = AB[:,0]
B = AB[:,1]
idx = B.argsort()
A = A[idx]
B = B[idx]
np.cumsum(A, out = A)
bl = (A <= B).all()
answer = 'Yes' if bl else 'No'
print(answer)


Measured memory_bytes: 49964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
const ll mod=1e9+7;

ll cl[200010],dp[200010];
vector<ll> last(200010,-1);

int main(){
    ll n;cin>>n;
    dp[0]=1;
    rep(i,0,n){
        ll a;cin>>a;
        if(last[a]==-1){
            dp[i+1]=dp[i];
            last[a]=i;
            cl[a]+=dp[i];
            cl[a]%=mod;
        }
        else if(last[a]==i-1){
            dp[i+1]=dp[i];
            last[a]=i;
        }
        else{
            dp[i+1]=dp[i]+cl[a];
            last[a]=i;
            cl[a]+=dp[i];
            cl[a]%=mod;
        }
        dp[i+1]%=mod;
    }
    cout<<dp[n]<<endl;
}
    









Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;

int bitCount(int bits) {
    int cnt = 0;
    for(int mask = 1; mask != 0; mask<<=1) {
        if( (bits & mask) != 0 )
            ++cnt;
    }
    return cnt;
}

int main(){
  int n; cin>>n;
  map<char,int> mp;
  rep(i,n){
    string a; cin>>a;
    if(a[0]=='M'||a[0]=='A'||a[0]=='R'||a[0]=='C'||a[0]=='H'){
      mp[a[0]]++;
    }
  }
  char d[5]={'M','A','R','C','H'};
  ll ans=0;
  for(int bit=0;bit<(1<<5);bit++){
    int bc=bitCount(bit);
    if(bc!=3) continue;
    ll c=1;
    rep(i,5){
      if((bit&(1<<i))!=0)
      c*=mp[d[i]];
    }
    ans+=c;
  }
  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    vector<ll> dp(n + 10, 1e15);
    rep(i, n)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    rep(i, n)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;
	static P[][] f;

	static int dfs(P c, int d) {
		int ret = 0;
		for (int i = 0; i < 4; ++i) {
			P n = c.neib[i];
			P next = n;
			if (n.home) {
				if (d == 0) return 1;
				next = n.neib[i];
			}
			if (next == NIL) continue;
			if (!c.home) {
				c.neib[(i + 2) % 4].neib[i] = c.neib[i];
				c.neib[i].neib[(i + 2) % 4] = c.neib[(i + 2) % 4];
				c.neib[(i + 1) % 4].neib[(i + 3) % 4] = c.neib[(i + 3) % 4];
				c.neib[(i + 3) % 4].neib[(i + 1) % 4] = c.neib[(i + 1) % 4];
			}
			ret += dfs(next, d - 1);
			if (!c.home) {
				c.neib[(i + 2) % 4].neib[i] = c;
				c.neib[i].neib[(i + 2) % 4] = c;
				c.neib[(i + 1) % 4].neib[(i + 3) % 4] = c;
				c.neib[(i + 3) % 4].neib[(i + 1) % 4] = c;
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		while (true) {
			M = sc.nextInt();
			N = sc.nextInt();
			if (N == 0) break;
			f = new P[N][M];
			int d = 0;
			P start = null;
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < M; ++j) {
					int v = sc.nextInt();
					if (v == 1) {
						++d;
						f[i][j] = new P();
					} else if (v == 2) {
						start = f[i][j] = new P();
						start.home = true;
					}
				}
			}
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < M; ++j) {
					if (f[i][j] != null) {
						for (int k = i + 1; k < N; ++k) {
							if (f[k][j] != null) {
								f[i][j].neib[0] = f[k][j];
								f[k][j].neib[2] = f[i][j];
								break;
							}
						}
						for (int k = j + 1; k < M; ++k) {
							if (f[i][k] != null) {
								f[i][j].neib[1] = f[i][k];
								f[i][k].neib[3] = f[i][j];
								break;
							}
						}
					}
				}
			}
			System.out.println(dfs(start, d));
		}
	}

	static class P {
		P[] neib = new P[4];
		boolean home;

		P() {
			Arrays.fill(neib, NIL);
		}

	}

	static P NIL = new P();

}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int mm = n * m;
        double tsubo = (double)n * m / 3.305785;
        System.out.println(tsubo);
    }
}



Measured memory_bytes: 26436
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [a, b] <- readInt
  if a <= b
    then put a
    else put $ a - 1


Measured memory_bytes: 380
#include "bits/stdc++.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define dbg(x)    { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)  { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define mod 1000000007
#define pb push_back
#define pii pair<int,int>
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio
    int a,b,c,d; cin>>a>>b>>c>>d;
    int x=max(a,b)*max(c,d);
    int y=max(a,b)*min(c,d);
    int z=min(a,b)*max(c,d);
    int zz=min(a,b)*min(c,d);
    cout<<max({x,y,z,zz});   
    

    return 0;


}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N,W;
int main(){
  cin>>N>>W;
  vector<vector<ll>>A(4);
  ll w1,v1;cin>>w1>>v1;
  A[0].push_back(v1);
  for(ll i=0;i<N-1;i++){
  ll w,v;cin>>w>>v;A[w-w1].push_back(v);
  }for(ll i=0;i<4;i++){
    sort(A[i].begin(),A[i].end());
    reverse(A[i].begin(),A[i].end());
  }vector<vector<ll>>B(4);
  B[0].push_back(0);B[1].push_back(0);
  B[2].push_back(0);B[3].push_back(0);
  for(ll i=0;i<4;i++)
    for(ll j=0;j<A[i].size();j++)
      B[i].push_back(A[i][j]);
   for(ll i=0;i<4;i++)
    for(ll j=1;j<B[i].size();j++)
      B[i][j]+=B[i][j-1];
  ll ans=0;
  for(ll i=0;i<B[0].size();i++)
    for(ll j=0;j<B[1].size();j++)
      for(ll k=0;k<B[2].size();k++)
        for(ll l=0;l<B[3].size();l++){
        if(w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l<=W)
          if(ans<B[0][i]+B[1][j]+B[2][k]+B[3][l])
            ans=B[0][i]+B[1][j]+B[2][k]+B[3][l];
         }cout<<ans<<endl;
  return 0;
}

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

int main(){
  int n,odd_count=0;
  cin >> n;
  vector<long long> data(n);
  for(int i=0; i<n; i++){
    cin >> data[i];
    if(data[i]%2 == 1){
      odd_count++;
    }
  }
  
  if(odd_count%2 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  } 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<string> S(3);
  rep(i, 3) cin >> S[i];
  int ans = 0;
  rep(i, N) {
    vector<int> alph(26);
    rep(j, 3) alph[int(S[j][i]-'a')]++;
    int mx = 0;
    rep(j, 26) mx = max(alph[j], mx);
    ans += 3-mx;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

void  bubbleSort(double number[], int length);



int main() {

	double  N, v[102];

	scanf("%lf", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &v[i]);
	}


	bubbleSort(v, (int)N);


	for (int i = N-1; i>0; i--) {
		v[i - 1] = (v[i - 1] + v[i]) / 2;
	}
	printf("%f", v[0]);




}


//---配列を降順ソート（だんだん小さくなる）----
void  bubbleSort(double number[], int length) {
	for (int i = 0; i < length; i++)
		for (int j = i + 1; j < length; j++)
			if (number[i] < number[j]) {
				double tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
}

Measured memory_bytes: 128
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    string S;  cin >> S;
    int N = S.size();
    
    int ans = 0;
    REP(i,N-1) {
        if (S[i] != S[i + 1]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import math

def isprime(n):
    if n <= 1:
        return False
    
    for k in range(2, int(math.sqrt(n))+1):
        if n%k ==0:
            return False
    return True

X = int(input())
flg = False

while flg!=True:
    flg = isprime(X)
    X = X + 1
print(X-1)

Measured memory_bytes: 3060
n,t = map(int,input().split())
ls = list(map(int,input().split()))
mn = 0
p = 0
for i in range(n-1):
    if ls[i+1] - ls[i] > t:
        p += ls[i]-mn+t
        mn = ls[i+1]
p += ls[-1]-mn+t
print(p)

Measured memory_bytes: 85328
using System;
using CompLib.Util;

public class Program
{
    private long T1, T2;
    private long A1, A2;
    private long B1, B2;

    public void Solve()
    {
        var sc = new Scanner();
        T1 = sc.NextLong();
        T2 = sc.NextLong();
        A1 = sc.NextLong();
        A2 = sc.NextLong();
        B1 = sc.NextLong();
        B2 = sc.NextLong();


        // A1のほうが大きいようにする
        if (A1 < B1)
        {
            long t = A1;
            A1 = B1;
            B1 = t;

            t = A2;
            A2 = B2;
            B2 = t;
        }

        long sA1 = A1 * T1;
        long sB1 = B1 * T1;
        long sA = sA1 + A2 * T2;
        long sB = sB1 + B2 * T2;

        // T1+T2ごとに会う
        if (sA == sB)
        {
            Console.WriteLine("infinity");
            return;
        }

        // 追いつけない
        if (sA > sB)
        {
            Console.WriteLine("0");
            return;
        }

        // 1が先行する
        // 2が追いつく

        // 1が先行できなくなる
        long diff = sB - sA;
        long d1 = sA1 - sB1;
        long ans;
        if (d1 % diff == 0)
        {
            ans = d1 / diff * 2;
        }
        else
        {
            ans = d1 / diff *2 + 1;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27308
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int k,n;
    cin>>k>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    std::vector<int> v;
    for (int i = 1; i < n; ++i)
    {
        v.pb(a[i]-a[i-1]);
    }
    v.pb(k+a[0]-a[n-1]);
    sort(rall(v));
    cout<<k-v[0];

    printclock;
    return 0;
}


Measured memory_bytes: 3956
package main

import (
	"fmt"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if b-a <= 0 {
		fmt.Println("delicious")
	} else if b-a <= x {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


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

using namespace std;

const long long MAX = (long long)INT_MAX;

int main(){
    int n,W;
    cin>>n>>W;
    long long sum=0,a[n],w[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>a[i];
        sum+=a[i];
    }
    vector<long long> dp(sum+1,MAX);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=sum;j>=a[i];j--){
            dp[j]=min(dp[j],dp[j-a[i]]+w[i]);
            //cout<<dp[j]<<" ";
        }
    }
    long long ans=0;
    for(long long i=0;i<=sum;i++){
        if(dp[i]<=W){
            //cout<<i<<" ";
            ans=max(ans,i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
				fast
                // #ifndef ONLINE_JUDGE
                // freopen("input.txt","r",stdin);
                // freopen("output.txt","w",stdout);
                // #endif
             ll n,m,sum=0;
             cin>>n>>m;
             ll arr[n];
             for(ll i=0;i<n;i++)
             {
                cin>>arr[i];
                sum+=arr[i];

             }
             ll v=(sum+(4*m)-1)/(4*m);
             //cout<<v;
             // ll v=(sum)/(4*m);
             ll count=0;
             for(ll i=0;i<n;i++)
             {
                if(arr[i]>=v)
                    count+=1;

             }
             if(count>=m)
                cout<<"Yes";
            else
                cout<<"No";

                return 0;
            }

Measured memory_bytes: 256
/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define vll vector<ll>
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
void solve(){
    int i,n;
        cin>>n;
        vll a(n+1,0);
        // a[0]=0;
        repf(i,1,n+1) cin>>a[i];
        ll b=0;
        ll ans=0;
        ans=ans+a[i]*b;
        repb(i,n,1)
        {
            // ans = (ans%mod+((a[i]%mod)*(b%mod))%mod)%mod;
            ans=(ans+((a[i]%mod)*(b%mod))%mod)%mod;
            // cout<<ans<<"\n";
            b+=a[i];
        }
        cout<<ans;
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin >> n>>m;
  ll k;cin >> k;
  UnionFind UF(n);
  vector<ll> fr(n,0);
  rep(i,m){
    ll a,b;cin >> a >> b;
    a--;b--;
    UF.unionSet(a,b);
    fr[a]++;
    fr[b]++;
  }
  vector<ll> v[n];
  rep(i,k){
    ll c,d;cin >> c >> d;
    c--;d--;
    v[c].push_back(d);
    v[d].push_back(c);
  }
  rep(i,n){
    ll ans = UF.size(i) - fr[i]-1;
    rep(j,v[i].size()){
      if(UF.findSet(i, v[i][j]))ans--;
    }
    cout << ans << " ";
  }


}

Measured memory_bytes: 7936
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)
#define printM(a, n, m) F(i, 0, n){ FE(j, 0, m) cout << a[i][j] << (i==m?'\n':' ');}

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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

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

#define printMatrix(mat,n,m){ \
    F(i, 0, n){               \
        F(j, 0, m){           \
            cout << mat[i][j] << space;\
        }\
        cout << endl;\
    }\
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int tmp = 0;
    string str;
    cin >> str;
    int ans = 0;
    F(i, 0, str.size()){
        if(str[i] == 'A' || str[i] == 'T' || str[i] == 'G' || str[i] == 'C'){
            tmp++;
            ans = max(tmp,ans);
        }else{
            tmp = 0;
        }
    }

#if TST==1
#endif
    cout << ans << endl;
}


Measured memory_bytes: 256
str_i = input()

length= len(str_i)
flag = 1

if (length%2 != 0):
    
    flag = 0
    
else:
    str_list_d = ""
    for i in range(int(length/2)):
        k = i*2
        str_list_d =  str_i[k]+str_i[k+1] 
        if(str_list_d != "hi"):
            flag = 0
            break


if (flag == 1):
    print("Yes")

else:
    print("No")
    
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C;
    cin >>A>>B>>C;
    if(A<=C && B>=C) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;



}


Measured memory_bytes: 256