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

#define mx 3005
typedef long long int ll;
ll a[mx];
ll dp[mx][mx][2];
ll cal(ll l,ll r,ll ok)
{
    if(l>r) return 0;
    if(dp[l][r][ok]!=-1) return dp[l][r][ok];
    if(ok==0){

        ll ans=max(a[l]+cal(l+1,r,!ok),cal(l,r-1,!ok)+a[r]);
        //cout<<l<<" "<<r<<" "<<ans<<endl;
        return dp[l][r][ok]=ans;
    }
    else{
        ll ans=min(cal(l+1,r,!ok)-a[l],cal(l,r-1,!ok)-a[r]);
        //cout<<l<<" "<<r<<" "<<ans<<endl;
        return dp[l][r][ok]=ans;
    }
}
int main()
{
    ll n,m;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++) cin>>a[i];
    cout<<cal(1,n,0)<<endl;
}


Measured memory_bytes: 144884
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long n;
	long long t=1;
	scanf("%lld",&n);
	for(int i=sqrt(n);i>=1;i--)
	{
		if(n%i==0)
		{
			long long k=n/i;
			while(k>=10)
			{
			    t++;
				k/=10;
			}
			break;
		} 
	} 
	printf("%lld\n",t);
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

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

bc_lst = []
for i in range(M):
	bc_lst.append(list(map(int,input().split())))

bc_lst.sort(key=lambda x:-x[1])

new_lst = []
for b,c in bc_lst:
	new_lst += [c for _ in range(b)]
	if len(new_lst) >= N:
		break

a_lst = a_lst+new_lst
a_lst.sort()


print(sum(a_lst[-N:]))

Measured memory_bytes: 92056
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array(sys.stdin.readlines(), dtype=np.int64)

for _ in range(N):
    left = A[::2]
    right = A[1::2]
    A = np.abs(left - right)

answer = A[0]
print(answer)

Measured memory_bytes: 45396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << n*n*n << endl;



  return 0;
    

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m;
  string s;
  cin >> n;
  vector<int> v(n);
  int sum=0;
  rep(i,n) {
    cin >> v[i];
    sum+=v[i];
  }
  cin >> m;
  vector<pair<int,int>> q(m);
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;
    pair<int,int> p=make_pair(x,y);
    q[i]=p;
  }
  rep(i,m){
    int tmp;
    tmp=sum;
    tmp-=v[q[i].first];
    tmp+=q[i].second;
    cout << tmp << endl;
  }


  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
template <typename T> 
bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M >> K;
  Vec(P,int,M*N,0);
  rep(i,0,M*N)P[i]=i/N;
  DV(Q,int,K,4,0);
  rep(i,0,K)rep(j,0,4)cin >> Q[i][j];
  do{
    sum=0;
    rep(i,0,K)if(P[Q[i][1]-1]-P[Q[i][0]-1]==Q[i][2])sum+=Q[i][3];
    chmax(num,sum);
  }while(next_combination(P.begin(),P.end(),N));
  Out(num);
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	int x = 0;
	rep(i, N) cin >> a[i], x ^= a[i];
	vector<int> d(N);
	rep(i, N) d[i] = a[i] ^ (a[i] - 1);
	vector<bool> c(31);
	rep(i, N) {
		int k = 0;
		for (; d[i]; d[i] /= 2) k++;
		c[k - 1] = true;
	}
	int ans = 0;
	for (int k = 30; k >= 0; k--)
		if (x>>k & 1) {
			if (!c[k]) {
				cout << -1 << endl;
				return 0;
			}
			x ^= (1<<(k + 1)) - 1;
			ans++;
		}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, d, a, ans = 0;
    cin >> n >> d >> a;
    vector<P> x(n);
    rep(i, n)cin >> x[i].first >> x[i].second;
    sort(all(x)); 
    vector<int> sum(n,0), b(n);
    rep(i, n)b[i] = x[i].first;
    rep(i, n){
        if(i)sum[i] += sum[i-1];
        int h = x[i].second, now = x[i].first;
        h -= sum[i] * a;
        if(h <= 0)continue;
        else{
            auto it = upper_bound(all(b), now+2*d);
            sum[i] += (h+a-1)/a;
            ans += (h+a-1)/a;
            if(it != b.end())sum[it-b.begin()] -= (h+a-1)/a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cmath>

#define INF 100000

using namespace std;

void chmin(int &a, int b) { if(a>b) a=b; }
void chmax(int &a, int b) { if(a<b) a=b; }

int N;
vector<int> A;

vector<int> L, R;

int rec(int a, int b){
	if(a==0) return b;
	if(b==0) return a;
	return rec(b, a%b);
}

int main() {
    cin >> N;
	A.resize(N);

	int min = 1000000000;
	int pm = 1;
	long long sum = 0;

    for(int i=0; i<N; i++) {
		int tmp; cin >> tmp;
		if(tmp > 0){

		}else if( tmp < 0){
			pm *= -1;
		}else{
			pm = 0;
		}
		sum += abs(tmp);
		chmin(min, abs(tmp));
	}

	if(pm >= 0) cout << sum << endl;
	else cout << sum - 2 * min << endl;
}

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

int main (void)
{
  int n,i,c=0;
  string s;
  cin>>n;
  cin>>s;
  rep(i,n-2)if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ++c;
  cout<<c;
    
  return 0;
  
}

Measured memory_bytes: 256
#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;
}
const int N=101,mod=1e9+7;
int f[N][4][4][4][4];
int main() {
	const int n=getint();
	for(register int i=0;i<4;i++) {
		for(register int j=0;j<4;j++) {
			for(register int k=0;k<4;k++) {
				f[3][0][i][j][k]=1;
			}
		}
	}
	f[3][0][1][2][3]=0;
	f[3][0][2][1][3]=0;
	f[3][0][1][3][2]=0;
	for(register int i=4;i<=n;i++) {
		for(register int j=0;j<4;j++) {
			for(register int k=0;k<4;k++) {
				for(register int l=0;l<4;l++) {
					for(register int m=0;m<4;m++) {
						for(register int n=0;n<4;n++) {
							(f[i][j][k][l][m]+=f[i-1][n][j][k][l])%=mod;
						}
					}
				}
			}
			f[i][j][1][2][3]=0;
			f[i][j][2][1][3]=0;
			f[i][j][1][3][2]=0;
		}
		for(register int j=0;j<4;j++) {
			f[i][1][2][j][3]=0;
			f[i][1][j][2][3]=0;
		}
	}
	int ans=0;
	for(register int i=0;i<4;i++) {
		for(register int j=0;j<4;j++) {
			for(register int k=0;k<4;k++) {
				for(register int l=0;l<4;l++) {
					(ans+=f[n][i][j][k][l])%=mod;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
K=int(input())
S=input()
M=len(S)
N=K+M
mod=10**9+7
ans=pow(26,N,mod)
class Data():
    def __init__(self):
        self.power=1
        self.rev=1     
class Combi():
    def __init__(self,N,mod):
        self.lists=[Data() for _ in range(N+1)]
        self.mod=mod  
        for i in range(2,N+1):
            self.lists[i].power=((self.lists[i-1].power)*i)%self.mod
        self.lists[N].rev=pow(self.lists[N].power,self.mod-2,self.mod)
        for j in range(N,0,-1):
            self.lists[j-1].rev=((self.lists[j].rev)*j)%self.mod

    def combi(self,K,R):
        if K<R:
            return 0
        else:
            return ((self.lists[K].power)*(self.lists[K-R].rev)*(self.lists[R].rev))%self.mod
        
c=Combi(2*10**6,mod)
for i in range(M):
    ans-=c.combi(N,i)*pow(25,N-i,mod)
    ans%=mod
print(ans)


Measured memory_bytes: 313484
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int f(int p){
  if(p == 1){
    return 300000;
  }else if(p == 2){
    return 200000;
  }else if(p==3){
    return 100000;
  }
  return 0;
}

 
int main() {
  int x,y;
  cin >> x >> y;
  int ans = 0;
  if(x == 1 && y == 1){
    ans += 400000;
  }
  
  ans += f(x) + f(y);
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
S = input()
N = len(S)

P = 2019

if P not in [2,5]:

    dic = {}
    dic[0] = 1
    now = 0
    ans = 0

    loop = 0
    for i in range(N-1,-1,-1):
        now += int(S[i]) * pow(10,loop,P)
        now %= P
        if now in dic:
            ans += dic[now]
            dic[now] += 1
        else:
            dic[now] = 1
        loop += 1

    print (ans)

elif P == 2:

    ans = 0
    for i in range(N):

        if int(S[i]) % 2 == 0:
            ans += i+1

    print (ans)

else:

    ans = 0

    for i in range(N):

        if int(S[i]) % 5 == 0:
            ans += i+1

    print (ans)
    


Measured memory_bytes: 68468
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
#define MOD 1000000007
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll n,ans=1;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		ans=(ans*i)%MOD;
	}
	cout<<ans;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll n, a;
  cin >> n >> a;

  if (n % 500 <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        if (N >= 10) {
        		System.out.println(R);
        } else {
        		System.out.println(R+(100*(10-N)));
        }
    }
} 

Measured memory_bytes: 21844
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,w = LI()
    aa = sorted([LI() for _ in range(n)])
    r = [0] * (w+1)
    mx = 0
    for a,b in aa:
        mx += a
        for i in range(min(mx, w-a),-1,-1):
            if r[i+a] < b + r[i]:
                r[i+a] = b + r[i]

    return max(r)


print(main())


Measured memory_bytes: 10128
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NumericUnderscores #-}
import Data.Char (isSpace)
import Data.List
import Control.Monad
import Control.Monad.Trans.Maybe
import Control.Monad.ST
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Test.QuickCheck as QC
import Data.Coerce

isPairwiseCoprime_naive :: Int -> U.Vector Int -> Bool
isPairwiseCoprime_naive _mbound xs = and [ gcd x y == 1 | x:ys <- tails (U.toList xs), y <- ys ]

toHistogram :: Int -> U.Vector Int -> U.Vector Int
toHistogram mbound xs = U.create $ do
  m <- UM.replicate (mbound + 1) (0 :: Int)
  U.forM_ xs $ \x -> do
    UM.modify m (+ 1) x
  return m

isPairwiseCoprime :: Int -> U.Vector Int -> Bool
isPairwiseCoprime !mbound !xs = maybe False (const True) $ runST $ runMaybeT $ do
  let !m = toHistogram mbound xs
  sieve <- UM.replicate (mbound + 1) True
  UM.write sieve 0 False
  UM.write sieve 1 False
  forM_ [2..mbound] $ \i -> do
    t <- UM.read sieve i
    when t $ do
      let loop !j !u | j > mbound = if u >= 2 then
                                      mzero
                                    else
                                      return ()
                     | otherwise = do
                         UM.write sieve j False
                         let !v = u + m U.! j
                         if v >= 2 then
                           mzero -- break
                         else
                           loop (j + i) v
      loop (2 * i) (m U.! i)
  return () -- The answer is "Yes" -- pairwise coprime

isSetwiseCoprime :: U.Vector Int -> Bool
isSetwiseCoprime xs = U.foldl' gcd 0 xs == 1 -- not best

main = do
  n <- readLn @Int
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let mbound = U.maximum xs
  if isPairwiseCoprime mbound xs then
    putStrLn "pairwise coprime"
  else if isSetwiseCoprime xs then
    putStrLn "setwise coprime"
  else
    putStrLn "not coprime"

prop :: QC.NonEmptyList (QC.Positive Int) -> QC.Property
prop xs' = let xs = U.fromList (coerce xs') :: U.Vector Int
               mbound = U.maximum xs
           in isPairwiseCoprime mbound xs QC.=== isPairwiseCoprime_naive mbound xs

runTest :: IO ()
runTest = QC.quickCheck $ QC.withMaxSuccess 1000 $ QC.mapSize (* 1000) prop


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int G = 0;
  for (auto a : A) G = gcd(G, a);
  if (G > 1) return cout << "not coprime" << "\n", 0;

  auto pf = [&](long n) {
    map<long, int> ret;
    for (long i = 2; i * i <= n; i++) {
      while (n % i == 0) ret[i]++, n /= i;
    }
    if (n != 1) ret[n]++;
    return ret;
  };

  vector<bool> B(1e6+1);
  for (int i = 0; i < N; i++) {
    for (auto [a, b] : pf(A.at(i))) {
      if (B.at(a)) return cout << "setwise coprime" << "\n", 0;
      else B.at(a) = true;
    }
  }
  cout << "pairwise coprime" << "\n";
}

Measured memory_bytes: 7396
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int pre[200010],n,x,minn; 
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		pre[i]=pre[i-1]+x;
	}
	int p1=1,p2=2,p3=3;
	long long ans=1e18;
	for(;p2<n;p2++){
		int minn=1e18,maxn=0;
		for(int i=p1;i<p2;i++)
			if(abs(pre[i]-(pre[p2]-pre[i]))<minn){
				minn=abs(pre[i]-(pre[p2]-pre[i]));
				p1=i;
			}
			else break;
		minn=1e18;
		if(p3<=p2)p3=p2+1;
		for(int i=p3;i<=n;i++)
			if(abs((pre[i]-pre[p2])-(pre[n]-pre[i]))<minn){
				minn=abs((pre[i]-pre[p2])-(pre[n]-pre[i]));
				p3=i;
			}
			else break;
		minn=1e18;
		minn=min(pre[p1],min(pre[p2]-pre[p1],min(pre[p3]-pre[p2],pre[n]-pre[p3])));
		maxn=max(pre[p1],max(pre[p2]-pre[p1],max(pre[p3]-pre[p2],pre[n]-pre[p3])));
		ans=min(ans,maxn-minn);		
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4784
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;


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

  cin>>n; P a[n];
  rep(i,n){
    cin>>x;
    a[i]=P(x,i+1);
  }
  sort(a,a+n);
  rep(i,n)cout<<a[i].second<<(i==n-1?'\n':' ');
  
}

Measured memory_bytes: 1664
import collections
N = int(input())
a = [min(int(i)//400,8) for i in input().split()]
b = collections.Counter(a)
tmp = 0
for i in range(8):
  if b[i] >= 1:
    tmp += 1
if tmp >= 1:
  amin = tmp
  amax = tmp+b[8]
else:
  amin = 1
  amax = tmp+b[8]
print(amin,amax)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

//        String a = "kyoto";
//        String b = "tokyo";
        //Scanner cin = new Scanner(new FileReader("src\\AtcoderContest0805\\task2-test-input.txt"));
        Scanner cin = new Scanner(System.in);
        String a = cin.nextLine();
        if (a.charAt(0)!='A') {
            System.out.println("WA");
            return;
        }

        int count = 0;
        for (int i=0;i<a.length();i++){
                if (a.charAt(i)=='C') count++;
        }
        if (count>1) {
            System.out.println("WA");
            return;
        }
        else if (count==0) {
            System.out.println("WA");
            return;
        }
        else {
            if (a.indexOf("C")==1||a.indexOf("C")==a.length()-1) {
                System.out.println("WA");
                return;
            }
        }

        for (int i=1;i<a.length();i++) {
            if (a.charAt(i)=='C') continue;
            char temp = a.charAt(i);
            if (!(temp>='a'&&temp<='z')) {
                System.out.println("WA");
                return;
            }
        }

        System.out.println("AC");
        return;
    }

}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // Failed to predict input format

    ll N, K;
    cin >> N >> K;
    vector<int> A(N+1);
    vector<int> distance(N+1, INT_MAX);
    rep(i,1,N+1) cin >> A[i];
    int previous = 1, current = 1;
    distance[1] = 0;
    int cycle = 0;
    rep(i,0,N) {
        current = A[current];
        if (distance[current] != INT_MAX) {
            cycle = distance[previous] - distance[current] + 1;
            break;
        }
        distance[current] = distance[previous] + 1;
        previous = current;
    }
    if (K > distance[current]) {
        K -= distance[current];
        K %= cycle;
        K += distance[current];
    }
    current = 1;
    rep(i,0,K) {
        current = A[current];
    }
    cout << current << endl;
    return 0;
}


Measured memory_bytes: 4848
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
    x, y, z = map(int, input().split())
    x, y = x-1, y-1
    graph[x].append(y)
    graph[y].append(x)
visited = [False for i in range(N)]
def bfs(v):
    Q = []
    visited[v] = True
    Q.append(v)
    while len(Q) > 0:
        v = Q.pop(0)
        for u in graph[v]:
            if not visited[u]:
                visited[u] = True
                Q.append(u)

count = 0
for i in range(N):
    if not visited[i]:
        bfs(i)
        count += 1
print(count)



Measured memory_bytes: 25648
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N = int(input())
L = list(itertools.permutations(list(range(1, N + 1)), N))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
for num, i in enumerate(L):
    if i == P:
        a = num
    if i == Q:
        b = num
print(abs(a - b))


Measured memory_bytes: 10080
import itertools
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
even_counter = Counter(V[::2])
odd_counter = Counter(V[1::2])
even_counter[-1] = 0
odd_counter[-1] = 0
even = even_counter.most_common(2)
odd = odd_counter.most_common(2)
ans = N
for (k1,v1),(k2,v2) in itertools.product(even,odd):
  if k1 == k2:
    continue
  ans = min(ans,N - v1 - v2)
print(ans)

Measured memory_bytes: 18548
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String s = scanner.nextLine();

        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R') {
                red++;
            } else {
                blue++;
            }
        }
        System.out.println(red > blue ? "Yes" : "No");
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e3 + 5;

char c[MAXN][MAXN];

void solve(){
	int n, m, a, b;
	scanf("%d%d%d%d", &n, &m, &a, &b);
	REP(i, 0, n) {
		REP(j, 0, m) {
			c[i][j] = '.';
		}
	}
	int n1 = n, m1 = m;
	if (n % 2 == 1) {
		REP(i, 0, m / 2) {
			if (a == 0) {
				break;
			}
			c[n - 1][2 * i] = '<';
			c[n - 1][2 * i + 1] = '>';
			a--;
		}
		n--;
	}
	if (m % 2 == 1) {
		REP(i, 0, n / 2) {
			if (b == 0) {
				break;
			}
			c[2 * i][m - 1] = '^';
			c[2 * i + 1][m - 1] = 'v';
			b--;
		}
		m--;
	}
	
	if (2 * (a + b) > n * m) {
		printf("NO\n");
		return;
	}
	
	if (2 * (a + b) == n * m && a % 2 == 1) {
		if (n1 % 2 == 1 && m1 % 2 == 1) {
			c[n1 - 1][m1 - 1] = 'v';
			c[n1 - 2][m1 - 1] = '^';
			c[n1 - 3][m1 - 1] = '>';
			c[n1 - 3][m1 - 2] = '<';
			c[n1 - 2][m1 - 3] = 'v';
			c[n1 - 3][m1 - 3] = '^';
			a--;
			b--;
		} else {
			printf("NO\n");
			return;
		}		
	}
	REP(i, 0, n / 2) {
		REP(j, 0, m / 2) {
			if (a > 0) {
				c[2 * i][2 * j] = '<';
				c[2 * i][2 * j + 1] = '>';
				a--;
				if (a > 0) {
					c[2 * i + 1][2 * j] = '<';
					c[2 * i + 1][2 * j + 1] = '>';
					a--;
				}
			} else if (b > 0) {
				c[2 * i][2 * j] = '^';
				c[2 * i + 1][2 * j] = 'v';
				b--;
				if (b > 0) {
					c[2 * i][2 * j + 1] = '^';
					c[2 * i + 1][2 * j + 1] = 'v';
					b--;
				}
			}
			
		}
	}
	
	printf("YES\n");
	REP(i, 0, n1) {
		printf("%s\n", c[i]);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);



// A = 5 B = 7  N = 4
// x=3 のとき、floor(Ax/B)−A×floor(x/B)=floor(15/7)−5×floor(3/7)=2 となり、これが最大です。

// A = 5 B = 7  N = 4
// x=3 のとき、floor(Ax/B)−A×floor(x/B)=floor(15/7)−5×floor(3/7)=2 となり、これが最大です。
/*
	8 40 / 7 - 5

	x = 15

	15 * 5 / 7 - 5 * 2
	75 / 7 - 10

*/

// ABC 166 D
// https://atcoder.jp/contests/abc165/tasks/abc165_d
int main()
{
	uint32_t a;
	uint64_t b,n;

	cin >> a >> b >> n;

	uint64_t x = (n < b) ? n : b - 1;

	uint64_t result = ((a * x) / b) - (a * (x / b));

	printf("%llu\n", result);
	return 0;
}


Measured memory_bytes: 3740
import sys
N = int(input())
if N == 1:
    print(0)
    sys.exit(0)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
L = factorization(N)
ans = []
for case in L:
    p = case[0]
    k = case[1]
    for i in range(1,k+1):
        ans.append(p**i)
ans.sort()
used = []
for el in ans:
    if el not in used and N % el == 0:
        N /= el
        used.append(el)
print(len(used))
sys.exit(0)

Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265
#define pb push_back
#define en cout<<'\n'
#define vec vector<ll>
#define vecs vector<string>
#define pii pair<ll,ll>
#define VP vector< pii >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x) ud __builtin_ctzll(x)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define mm " "
#define MM " "
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fa(x,v) for(auto x:v)
#define INF (ll)(9e18)
#define Sort(v) sort(v.begin(),v.end())
#define test ll T;cin>>T;while(T--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(a,max3(b,c,d))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())



int main()
{
fast;


    ll n;
    cin>>n;
    ll res=1000-n%1000;
    if(n%1000==0)res=0;
    cout<<res;
















    
}

Measured memory_bytes: 3644
X = int(input())
INF = 1000
A = [i ** 5 for i in range(INF)]
B = [i ** 5 for i in range(INF)]

def solve():

    for i in range(INF):
        for j in range(INF):
            if X == A[i] - B[j]:
                print(i, j)
                return

    for i in range(INF):
        for j in range(INF):
            if X == A[i] + B[j]:
                print(i, -j)
                return

    for i in range(INF):
        for j in range(INF):
            if X == -A[i] - B[j]:
                print(-i, j)
                return

    for i in range(INF):
        for j in range(INF):
            if X == -A[i] + B[j]:
                print(-i, -j)
                return
            
solve()

Measured memory_bytes: 65384
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

ans = 0
for j in t:
    s.append(j)
    i = 0
    while s[i] != j:
        i += 1
    if i >= n:
        pass
    else:
        ans += 1
print(ans)

Measured memory_bytes: 7764
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<sstream>
#include<functional>
#include<algorithm>
using namespace std;
string hiku(string a,string b){
	stringstream t1,t2,t3;
	int x=0,y=0,ans=0;
	t1<<a;
	t2<<b;
	t1>>x;
	t2>>y;
	ans=x-y;
	t3<<ans;
	string tmp=t3.str();
	return tmp;
	
}
int main(){
	string a;
	int k;
	while(true){
		vector<pair<string,int> >y;
		y.clear();
		cin>>a>>k;
		if(a=="0"&&k==0)break;
		for(int jf=0;jf<22;jf++){
		while(a.size()<k&&a.size()!=k)a="0"+a;
			pair<string,int>tmp=make_pair(a,jf);
			y.push_back(tmp);
			string t1,t2;
			sort(a.begin(),a.end());
			t1=a;
			sort(a.begin(),a.end(),greater<char>());
			t2=a;
			a=hiku(t2,t1);
		}
		int I=10e8,J=I;
		for(int i=0;i<y.size();i++){
			int cnt=0;
			while(y[i].first[cnt]=='0'){
			if(y[i].first=="0")break;
			y[i].first.erase(y[i].first.begin());
			}
		}
		bool f=1;		
		for(int i=0;i<y.size();i++){
			for(int j=0;j<y.size();j++){
				if(i==j)continue;
				if(y[i].first==y[j].first&&j<i&&f){
				if(I>i){
				I=i;
				J=j;
				f=0;
				}
				}
			}
		}
		cout<<J<<" "<<y[I].first<<" "<<I-J<<endl;
	}
	return 0;
}

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

def main():
    A, B, C = map(int, open(0).read().split())

    if A == B == C and A % 2 == 0:
        print(-1)
    elif A % 2 or B % 2 or C % 2 == 1:
        print(0)
    else:
        cnt = 0
        for i in range(0, max(A, B, C)):
            if A % 2 or B % 2 or C % 2 == 1:
                break
            else:
                tmpA = B//2 + C//2
                tmpB = A//2 + C//2
                tmpC = A//2 + B//2
                A = tmpA
                B = tmpB
                C = tmpC
                cnt += 1
        print(cnt)


main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
using namespace std;
using ll=long long;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }
#define mod 1000000007

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

    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        Set<String> list = new HashSet<>();
        for (int i = 0; i < a; i++) list.add(sc.next());
        System.out.println(list.size());
    }
}


Measured memory_bytes: 78104
#include    <stdio.h>
#include    <string.h>
#include    <stdlib.h>

int verbose = 1;
int main(void)
{
    long int	a, b, v, w, t;

    if (fscanf(stdin, "%ld %ld", &a, &v) == EOF) {
	printf("NO\n");
    }
    if (fscanf(stdin, "%ld %ld", &b, &w) == EOF) {
	printf("NO\n");
    }
    if (fscanf(stdin, "%ld", &t) == EOF) {
	printf("NO\n");
    }

    if (v <= w) {
	printf("NO\n");
    } else {
	if (labs(a - b) <= (v - w) * t) {
	    printf("YES\n");
	} else {
	    printf("NO\n");
	}
    }
    return 0;
}


Measured memory_bytes: 1600
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

ll n,m;
vector<ll> a;
ll count1[200002];

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

bool happy(ll x){
  ll k = 0;
  for(int i=0;i<a.size();i++){
    k += n - count1[max(0ll,(x - a[i]-1))];
  }
  if(k >= m) return true;
  else return false;
}

int main(){
  int n;
  cin >> n;
  ll c[n];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(c,c+n);
  reverse(c,c+n);
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += c[i]*(i+2);
    ans %= MOD;
  }
  for(int i=0;i<n-1;i++){
    ans *= 4;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main()
{
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, k){
        vi c(n+1, 0);
        rep(j, n){
            int l = max(0, j-a[j]);
            int r = min(n, j+a[j]+1);
            c[l]++;c[r]--;
        }
        rep(i, n) c[i+1] += c[i];
        c.pop_back();
        if (a==c) break;
        a = c;
        
    }
    rep(i, n-1) cout << a[i] << " ";
    cout << a.back() << endl;
    return 0;
}

Measured memory_bytes: 4804
#include<stdio.h>
int main(){
    double x1,x2,x3,x4,y1,y2,y3,y4;
    while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)){
        bool ok1=true;
        bool ok2=true;
        if((x2-x1)*(y4-y1)-(x4-x1)*(y2-y1)<0)ok1=false;
        else ok2=false;
        if((x3-x2)*(y4-y2)-(x4-x2)*(y3-y2)<0)ok1=false;
        else ok2=false;
        if((x1-x3)*(y4-y3)-(x4-x3)*(y1-y3)<0)ok1=false;
        else ok2=false;
        printf((ok1||ok2)?"YES\n":"NO\n");
    }
}

Measured memory_bytes: 1040
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S; cin >> S;
    bool T = true;
    for (int i = 0; i < S.length(); ++i) {
        if ((i + 1) % 2 == 0) {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') continue;
            else {
                T = false;
                break;
            }
        }
        else {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') continue;
            else {
                T = false;
                break;
            }
        }
    }
    if (T) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}


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

int main() {
	int h, w;
	cin >> h >> w;

	vector<vector<int>> s(h, vector<int>(w, 0));
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c; cin >> c;
			a[i].push_back(c);
		}
	}

	int ans = 0;
	int cnt = 0;

	for (int i = 0; i < h; i++) {
		cnt = 0;
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '.')
				cnt++;
			else 
				cnt = 0;
			s[i][j] += cnt;
		}
		// printss(s);
		cnt = 0;
		for (int j = w - 1; j >= 0; j--) {
			s[i][j] += cnt;
			if (a[i][j] == '.')
				cnt++;
			else 
				cnt = 0;
		}
	}

	for (int j = 0; j < w; j++) {
		cnt = 0;
		for (int i = 0; i < h; i++)
			s[i][j] += (a[i][j] == '.' ? ++cnt : cnt=0);

		cnt = 0;
		for (int i = h - 1; i >= 0; i--) 
			s[i][j] += (a[i][j] == '.' ? cnt++ : cnt=0);

	}

	for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++)
			ans = max(ans, s[i][j] - 1);
	cout << ans;
}

Measured memory_bytes: 20096
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

long long int gcd(long long int a, long long int b) {
  long long int rem = 1;
  while (rem) {
    rem = a % b;
    a = b;
    b = rem;
  }
  return a;
}

int main() {
  long long int a, b, c, d;
  scanf("%lld %lld %lld %lld", &b, &a, &c, &d);
  long long int g = c*d/gcd(c, d);
  a = a - a/c - a/d + a/g;
  DEBUG(printf("%lld\n", a);)
  b--;
  b = b - b/c - b/d + b/g;
  DEBUG(printf("%lld\n", b);)
  printf("%lld\n", a - b);
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 062 B / Link: http://abc062.contest.atcoder.jp/tasks/abc062_b  ----- */


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

	LL H, W; cin >> H >> W;
	vector<string> s(H);
	cout << string(W + 2, '#') << endl;;
	for (int i = 0; i < H; ++i) {
		cin >> s[i];
		cout << string(1, '#');
		cout << s[i];
		cout << string(1, '#')<<endl;
	}
	cout << string(W + 2, '#') << endl;;

	

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <stack>
#define int long long
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    vector<int>a;
    int n;
    int min1 = 19999999999;
    int ans = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int t;
        cin >> t;
        if(min1>t){
            min1=t;
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, L, ans=0;

	cin >> N >> L;

	pii mn = pii(INF, INF);
	rep(i,N){
		int val = L + i;
		chmin(mn, pii(abs(val), val));
		ans += val;
	}

	cout << ans - mn.Y << endl;

	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	cout << N * (N-1) / 2 + M * (M-1) / 2 << '\n';

	return 0;
}


Measured memory_bytes: 256
S = input()
S01 = int(S[0] + S[1])
S23 = int(S[2] + S[3])
if 0 < S01 < 13 and 0 < S23 < 13:
        print("AMBIGUOUS")
elif 0 < S01 < 13 and (S23 > 12 or S23 == 0):
        print("MMYY")
elif (S01 > 12 or S01 == 0) and 0 < S23 < 13:
        print("YYMM")
else:
        print("NA")

Measured memory_bytes: 3064
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd_list([abs(c - X) for c in cities])

print(ans)


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

using namespace std;

class Heap{
private:
 enum HEAPSIZE {SIZE = 250};
 vector<long> node;
public:
 Heap(){
  node.push_back(0);
 };

 void print(){
  int n = node.size();
  for(int i = 1; i < n; i++){ 
   cout << "node " << i << ": ";
   cout << "key = " << node[i] << ", ";
   if(i != 1)
    cout << "parent key = " << node[parent(i)] << ", ";
   if(left(i) < n)
    cout << "left key = " << node[left(i)] << ", ";
   if(right(i) < n)
    cout << "right key = " << node[right(i)] << ", ";
   cout << endl;
  }

 };

 void insert(long value){
  node.push_back(value);
 };

 long parent(long num){
  return (num / 2);
 };

 long left(long num){
  return (num * 2);
 };

 long right(long num){
  return (num * 2 + 1);
 };
 
protected:
};

int main(){
 int n = 0; cin >> n;
 Heap heap;

 for(int i = 0; i < n; i++){
  long num = 0; cin >> num;
  heap.insert(num);
 }

 heap.print(); 
 
 return 0;
}

Measured memory_bytes: 1220
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
 
number1 = [a, b, c, d, e]
number2 = [b, c, d, e]
count = 0
 
for num1 in number1:
  for num2 in number2:
    if abs(num1 - num2) <= k:
      count += 1
if count == 20:
  print('Yay!')
else:
  print(':(')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int rating;
  int kyu;
  cin >> rating;
  if (rating < 600) {
    kyu = 8;
  }
  else if (rating < 800) {
    kyu = 7;
  }
  else if (rating < 1000) {
    kyu = 6;
  }
  else if (rating < 1200) {
    kyu = 5;
  }
  else if (rating < 1400) {
    kyu = 4;
  }
  else if (rating < 1600) {
    kyu = 3;
  }
  else if (rating < 1800) {
    kyu = 2;
  }
  else if (rating < 2000) {
    kyu = 1;
  }
    cout << kyu << endl;
}





Measured memory_bytes: 3572