akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.Math;

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

        int n = sc.nextInt();
        String s = sc.next();

        int max = 0;

        for (int i = 0; i < n - 1; i++) {
            int cnt = 0;
            boolean isExist[] = new boolean[26];
            for (int j = 0; j < n; j++) {
                int index = (int)s.charAt(j) - (int)'a';
                if (j <= i) {
                    isExist[index] = true;
                } else {
                    if (isExist[index]) {
                        cnt++;
                        isExist[index] = false;
                    }
                }
            }
            if (max < cnt) {
                max = cnt;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
bool is_possible(int64_t target, const int64_t k, const vector<int> a, const vector<int> f) {
    const int n = a.size();
    int64_t cost = 0;
    rep(i, n) {
        int64_t need = target / f[i];
        cost += max(0LL, (LL)a[i] - need);
    }
    return cost <= k;

}
int main() {
    int n; uint64_t k; cin >> n >> k;
    vector<int> a(n);
    for (auto &v: a) cin >> v;
    vector<int> f(n);
    for (auto &v: f) cin >> v;

    sort(a.begin(), a.end(), greater<>());
    sort(f.begin(), f.end());

    int64_t left = -1, right = 1e18;
    while (abs(left - right) > 1) {
        int64_t mid = (left + right) / 2;
        if (is_possible(mid, k, a, f)) {
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
    return 0;
}


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

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i =  (n) - 1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  int n, k;
  cin >> n >> k;
  int ls[n];

  REP(i, n) {
    int l;
    cin >> l;
    ls[i] = l;
  }

  sort(ls, ls+n,greater<int>());

  int result = 0;
  REP(i, k) {
    result += ls[i];
  }

  cout << result << endl;
}



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

using namespace std;

#define mod1 1000000007
#define mod2 998244353
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
// #define endl "\n"

const int maxn=2e5+5;

int v[maxn];
int ar[maxn];

void solve()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>ar[i];
	sort(ar,ar+n);
	
	for(int i=0;i<n;i++)
		v[i]=0;
	v[n-1]=1;
	int tot=1;
	for(int j=n-2;j>=0 and tot<n-1;j--,tot+=2)
	{
		if(tot+2>n-1)
		{
			v[j]=1;
			break;
		}
		v[j]=2;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=v[i]*ar[i];
	}
	cout<<endl;
	cout<<ans<<endl;

}	

int32_t main()
{
	fio;
	int t;
	// cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 6780
#include <iostream>
#include <string>
#include <iomanip>

int main(int argc, char *argv[])
{
    int r;

    std::cin >> r;

    std::cout << std::setprecision(16) << static_cast<double>(r) * 2.0 * 3.14159265358979 << std::endl;

    return 0;
}


Measured memory_bytes: 3788
main :: IO ()
main = interact $ unlines . map (box . strToIntList) . takeWhile (/="0 0") . lines

strToIntList :: String -> (Int, Int)
strToIntList s = (x, y) where x:y:_ = map read . words $ s

box :: (Int, Int) -> String
box = unlines . rows

rows :: (Int, Int) -> [String]
rows (h, w)
    | h >= 3 && w >= 3  = [cover] ++ contents ++ [cover]
    | otherwise         = replicate h cover
    where cover    = replicate w '#'
          contents = replicate (h-2) $ "#" ++ replicate (w-2) '.' ++ "#"

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
long long ans;
int main()
{
	cin>>n>>a>>b;
	long long x=n/(a+b);
	if(a==0)
	{
		cout<<0;
		return 0;
	}
	ans+=x*a;
	if(n%(a+b)>a)
	{
		ans+=a;
	}
	else
	{
		ans+=n%(a+b);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 200005;

int pos[MAX_N][26], N, f[MAX_N];
char s[MAX_N];

int main() {
  scanf("%s", s + 1), N = strlen(s + 1);
  for (int i = 0; i < 26; ++i) pos[N + 1][i] = N + 1;
  
  for (int i = N; i; --i) {
    memcpy(pos[i], pos[i + 1], sizeof pos[i]);
    pos[i][s[i] - 'a'] = i;
  }

  f[N + 1] = 0;
  for (int i = N; i; --i) {
    int mn = N + 1;
    for (int j = 0; j < 26; ++j)
      if (f[pos[i + 1][j]] < mn)
	mn = f[pos[i + 1][j]];
    f[i] = mn + 1;
  }
  
  int now = 0;
  while (now < N + 1) {
    int mn = N + 1, mnid = 0;
    for (int i = 0; i < 26; ++i)
      if (f[pos[now + 1][i]] < mn)
	mn = f[pos[now + 1][i]], mnid = i;
    putchar(mnid + 'a');
    now = pos[now + 1][mnid];
  }
  puts("");
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }

    ll ans = gcd(A[0],A[1]);
    for(ll i= 2; i<N; i++){
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int hantei, an1, an2, n;
    char s[100], r[100], r_h[100];
    scanf("%s",s);

    for(int n_=1;s[n_] !='\0';n_++){
        n = n_;
    }
    n = n+1;
    
    for(int i=0;i<n;i++){
        r[i] = s[n-1-i];
    }

    for(int i=0;i<((n-1)/2);i++){
        r_h[i] = s[(n-1)/2-1-i];
    }
    

    hantei=0;

    for(int i=0;i<(n-1)/2;i++){
        if(s[i] != r_h[i]){hantei++;}
    }

    for(int i=0;i<n;i++){
        if(s[i] != r[i]){hantei++;}
    }

    if(hantei){
        cout << "No";
    }else{
        cout << "Yes";
    }




}

Measured memory_bytes: 256
S = input()
SS = list(S)
boo = False
boo2 = False
s1 = S[0]
s2 = S[1]
s3 = S[2]
s4 = S[3]
buf = ""
if s1 == s2:
    buf =SS.pop(1)
    buf =SS.pop(0)
elif s1 == s3:
    buf=SS.pop(2)
    buf=SS.pop(0)
elif  s1 == s4:
    buf=SS.pop(3)
    buf=SS.pop(0)
elif s2 == s3:
    buf=SS.pop(2)
    buf=SS.pop(1)
elif s2 == s4:
    buf=SS.pop(3)
    buf=SS.pop(1)
elif s3 == s4:
    buf=SS.pop(3)
    buf=SS.pop(2)
    
if len(SS) == 4:
    print("No")
elif SS[0] == SS[1] and buf != SS[0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long giant;
const ull base0=998244353ull;
const ull invr0=996491785301655553ull;
const giant q=1e9+7;
const giant base1=1232351;
const giant invr1=547430890;
const int maxn=2.5e5+3;
const int maxl=5e5+10;
struct H {
	ull x;
	giant y;
	explicit H ():x(0),y(0) {}
	explicit H (ull _x,giant _y):x(_x),y(_y) {}
	inline H& operator = (const int &k) {
		x=k,y=k;
		return *this;
	}
	inline H& operator *= (const H &h) {
		x*=h.x,y=(y*h.y)%q;
		return *this;
	}
	inline H& operator += (const H &h) {
		x+=h.x,y=(y+h.y)%q;
		return *this;
	}
	inline H& operator -= (const H &h) {
		x-=h.x,y=((y-h.y)%q+q)%q;
		return *this;
	}
	inline friend H operator * (H a,const H &b) {
		return a*=b;
	}
	inline friend H operator + (H a,const H &b) {
		return a+=b;
	}
	inline bool operator < (const H &h) const {
		return x!=h.x?(x<h.x):(y<h.y);
	}
} base(base0,base1),invr(invr0,invr1);
namespace num {
	H _mi[maxl],*mi=_mi+maxn;
	void init() {
		mi[0]=1;
		for (int i=1;i<maxn;++i) mi[i]=mi[i-1]*base;
		for (int i=1;i<maxn;++i) mi[-i]=mi[-i+1]*invr;
	}
	int __initer__=(init(),0);
}
int n;
char s[maxn];
map<H,int> mp;
namespace has {
	H val[maxn],cur;
	int pos[maxn];
	void deal(int &p,char c) {
		if (c=='<') --p; else
		if (c=='>') ++p; else
		if (c=='+') cur+=num::mi[p]; else
		if (c=='-') cur-=num::mi[p]; else
		assert(false);
	}
	H work() {
		int p=0;
		for (int i=1;i<=n;++i) {
			deal(p,s[i]);
			val[i]=cur;
			pos[i]=p;
		}
		return cur;
	}
}
int main() {
	scanf("%d%s",&n,s+1);
	H all=has::work();
	giant ans=0;
	for (int i=n;i>=0;--i) {
		H tmp=all*num::mi[has::pos[i]]+has::val[i];
		ans+=mp[tmp];
		++mp[has::val[i]];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 44416
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



string s, t;
int n, m, dp[1010][1010];

signed main() {
    cin >> s >> t;
    n = s.size(), m = t.size();
    rep(i,1010) rep(j,1010) dp[i][j] = 1<<30;
    rep(i,n) dp[i][0] = i;
    rep(i,m) dp[0][i] = i;
    rep(i,n) rep(j,m) {
        int c = s[i]!=t[j];
        chmin(dp[i+1][j+1], min({dp[i][j]+c, dp[i][j+1]+1, dp[i+1][j]+1}));
    }
    cout << dp[n][m] << endl;
}



Measured memory_bytes: 7220
import java.util.Scanner;

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

		String s = sc.nextLine();
		System.out.println(
				s.contains("1") &&
				s.contains("9") &&
				s.contains("7") &&
				s.contains("4") ? "YES" : "NO");

		sc.close();
	}
}



Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
void GG(){
	puts("No"); exit(0);
}
void add(int x,int y){
	wri(x); writeln(y);
}
int main(){
	int n=read(),f=0;
	for(int i=n;i>1;i>>=1)if(i&1)f=1;
	if(!f)GG();
	else{
		puts("Yes");
		add(n+1,3);
		for(int i=2;i<n;i+=2){
			add(i,i+1);
			add(i,1);
			add(i+1+n,1);
			add(i+1+n,i+n);
		}
		if(n%2==0){
			int t=n+1;
			For(i,2,t-1)if((t^i)<n){
				add(n,(i&1)?i+n:i);
				add(2*n,((t^i)&1)?(t^i)+n:(t^i));
				return 0;
			}
			while(1);
		}
	}
}

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

#define int long long int

int32_t main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int ans=0,sim=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==i+1)sim++;
        else
        {
            ans+=(sim+1)/2;
            sim=0;
        }
    }
    ans+=(sim+1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 4428
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize1; n],
    }
    println!("{}", a.iter().sum::<usize>());
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main(void)
{
    int N;
    scanf("%i", &N);
    if (N % 10 == 7 || N / 10 % 10 == 7 || N / 100 % 10 == 7)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1612
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = (int) sc.nextLong();
		long k = sc.nextLong();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = (int) (sc.nextLong()-1);
		}
		boolean[] visited = new boolean[n];
		visited[0] = true;
		List<Integer> set = new ArrayList<>(2*n);
		int pos = 0;
		int cycleStart = 0;
		int cycleEnd = n;
		set.add(0);
		for (int i = 0; i < n; i++) {
			
			if( visited[a[pos]]) {
				int index = set.indexOf(a[pos]);
				cycleStart = index;
				cycleEnd = i+1;
				break;
			}
			visited[a[pos]] = true;
			set.add(a[pos]);
			pos = a[pos];
		}
		
		int l = cycleEnd - cycleStart;
		long fixK = (k - cycleStart) % l + cycleStart;
		
		System.err.println( cycleStart);
		System.err.println( cycleEnd);
		System.err.println( fixK);
		System.err.println( set);
		if( k<cycleStart) {
			System.out.println( set.get((int)k) + 1);
		} else {
			k -= cycleStart;
			k %= l;
			k += cycleStart;
			System.out.println( set.get((int)k) + 1);
			
		}
		
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 57392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 3e5 + 10;
int n;
typedef pair<int, int>pii;
pii id(int x) {
	return pii((x - 1) / n + 1, (x - 1) % n + 1);
}
int dx[]{ 0,0,-1,1 };
int dy[]{ -1,1,0,0 };
int d[510][510], gg[510][510];
bool ilg(int x, int y) {
	return x<1 || y<1 || x>n || y>n;
}
void bfs(pii p) {
	queue<pii>q;
	q.push(p);
	while (!q.empty()) {
		int x = q.front().first, y = q.front().second; q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if (ilg(nx, ny) || d[nx][ny] <= d[x][y] + gg[x][y])continue;
			d[nx][ny] = d[x][y] + gg[x][y];
			q.push(pii(nx, ny));
		}
	}
}
int main() {
	scanf("%d", &n);
	int ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			d[i][j] = min(min(n - i, n - j), min(i - 1, j - 1)), gg[i][j] = 1;
	for (int i = 0; i < n*n; i++) {
		int x, y;
		scanf("%d", &x);
		pii p = id(x);
		x = p.first, y = p.second;
		int tmp = INF;
		for (int j = 0; j < 4; j++) {
			int nx = x + dx[j], ny = y + dy[j];
			tmp = min(tmp, d[nx][ny] + gg[nx][ny]);
		}
		ans += tmp;
		d[x][y] = tmp;
		gg[x][y] = 0;
		bfs(p);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {
	int A, B, X;
	cin >> A >> B >> X;

	if (A <= X&&X <= A + B) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# 素数ならTrue、素数でなければFalseを返す
def is_prime(x):
    sqrt = int(x ** 0.5)
    for i in range(2, sqrt + 1):
        if x % i == 0:
            return False
    return True

x = int(input())

while(not is_prime(x)):
    x += 1

print(x)


Measured memory_bytes: 9288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=2001 ;
int main()
{
   fast ;
   ll a,b,c,d ;
   cin>>a>>b>>c>>d ;

   ll x=(a+d-1)/d ;
   ll y=(c+b-1)/b ;

   if(x>=y)
    cout<<"Yes" ;
   else
    cout<<"No" ;




}



Measured memory_bytes: 3636
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
module Main where

import Control.Applicative
import Control.Monad
import Text.Printf         (printf)

main :: IO ()
main = do
    xs <- map (map read . words) . lines <$> getContents :: IO [[Double]]
    forM_ xs $ \[a,b,c,d,e,f] -> do
        let x = (b * f - c * e) / (b * d - a * e)
            y = (a * f - c * d) / (a * e - b * d)
        printf "%.3f %.3f\n" (round' 3 x) (round' 3 y)
  where
    round' :: RealFrac a => Int -> a -> a
    round' n x = fromIntegral (floor (0.5 + x * 10^n)) / 10^n

Measured memory_bytes: 4472
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

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

    int sta[200001] = {0};
    int goa[200001] = {0};
    int n,m;
    int str_sta, str_goa;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        cin >> str_sta >> str_goa;
        if(str_sta == 1)    sta[str_goa] = 1;
        if(str_sta == n)    goa[str_goa] = 1;
        if(str_goa == 1)    sta[str_sta] = 1;
        if(str_goa == n)    goa[str_sta] = 1;
        
    }
    bool flag = false;
    for(int i = 1; i < 200001; i++){
        if(sta[i] == 1){
            if(goa[i] == 1){
                flag = true;
                break;
            }
        }
    }
    if(flag)    cout << "POSSIBLE\n";
    else{
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
#define lop(i, s, t) for (int i = s;i < (t);++i)
#define rep(i, s, t) for (int i = s;i <= (t);++i) 
#define dec(i, s, t) for (int i = s;i >= (t);--i)
#define cmin(a, b) (a > b ? a = b : a)
#define cmax(a, b) (a < b ? a = b : a)
using namespace std; 

#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

const int N=1e6+60,P=1e9+7;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

typedef long long ll;

int n,fac[N],inv[N],ans;

int C(int n,int m){
	if(m<0||m>n||n<0)return 0;
	return mul(fac[n],mul(inv[n-m],inv[m])); 
}

int main() {
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout); 
#endif
	scanf("%d",&n); 
	if(n==2){ return puts("1"),0; }
	fac[0]=1; rep(i,1,n)fac[i]=mul(fac[i-1],i); 
	inv[1]=1; rep(i,2,n)inv[i]=mul(P-P/i,inv[P%i]); 
	inv[0]=1; rep(i,1,n)inv[i]=mul(inv[i-1],inv[i]);
	ans=mul(n-1,fac[n-1]); 
	rep(k,1,n-2){
		int w=mul(C(k-1,n-k-1),mul(fac[k],fac[n-1-k]));
		ans=sub(ans,w); 
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define MAX 200005

struct Edge{
	Edge(int arg_diff,ll arg_cost){
		diff = arg_diff;
		cost = arg_cost;
	}

	int diff;
	ll cost;
};

struct Info{
	Info(int arg_x,ll arg_sum_cost){
		x = arg_x;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{

		return sum_cost > arg.sum_cost; //総コストの昇順(PQ)
	}
	int x;
	ll sum_cost;
};

bool rangeCheck(int x){

	return x >= 0 && x < MAX;
}

int N;
int goal;
vector<Edge> edge;
ll min_cost[MAX];

int main(){

	scanf("%d %d",&N,&goal);

	int diff;
	ll cost;

	for(int i = 0; i < N; i++){

		scanf("%d %lld",&diff,&cost);
		edge.push_back(Edge(diff,cost));
	}

	for(int i = 0; i < MAX; i++){

		min_cost[i] = HUGE_NUM;
	}

	priority_queue<Info> Q;

	min_cost[0] = 0;
	Q.push(Info(0,0));

	while(!Q.empty()){

		if(Q.top().sum_cost > min_cost[Q.top().x]){

			Q.pop();

		}else if(Q.top().x == goal){

			printf("%lld\n",Q.top().sum_cost);
			return 0;

		}else{

			for(int i = 0; i < N; i++){

				ll next_cost = Q.top().sum_cost+edge[i].cost;

				int left = Q.top().x-edge[i].diff;
				if(rangeCheck(left) == true && min_cost[left] > next_cost){

					min_cost[left] = next_cost;
					Q.push(Info(left,next_cost));
				}

				int right = Q.top().x+edge[i].diff;
				if(rangeCheck(right) == true && min_cost[right] > next_cost){

					min_cost[right] = next_cost;
					Q.push(Info(right,next_cost));
				}
			}

			Q.pop();
		}
	}

	printf("-1\n");

	return 0;
}



Measured memory_bytes: 8548
//Limited Insertion

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,b);
    vector<int>ans(n);
    rep(i,0,n){
        for(int j=b.size()-1;j>=-1;j--){
            if(j==-1){
                cout<<-1<<nnn;
                return 0;
            }else if(b[j]==j+1){
                ans[n-1-i]=b[j];
                b.erase(b.begin()+j);
                break;
            }
        }
    }
    rep(i,0,n)cout<<ans[i]<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	int last = N % 10;
	
	if(last == 2 || last == 4 || last == 5 || last == 7 || last == 9){
		cout << "hon" << endl;
	}
	else if(last == 0 || last == 1 || last == 6 || last == 8){
		cout << "pon" << endl;
	}else{
		cout << "bon" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;
typedef long long int ll;

int main()
{
	ll N,M;
	scanf("%lld %lld",&M,&N);
	ll L=0,R=N+M;
	while(R-L>1)
	{
		ll m=(L+R)/2;
		
		ll c=max(0LL,m-M);
		if(N-2LL*c>=2LL*m) L=m;
		else R=m;
	}
	printf("%lld\n",L);
	return 0;
}


Measured memory_bytes: 128
s = input()


def get_change_nums(start,s):
    count = 0
    for p in enumerate(s):
        i,x = p
        if int(x) != (i + start) % 2:
            count += 1
    return count
    
s0 = get_change_nums(0,s)
s1 = get_change_nums(1,s)

print(min(s0,s1))



Measured memory_bytes: 3188
using System;

class Program
{
    static void Main(string[] args)
    {
        int r, c, i, j;
        int subTotal = 0;
        int total = 0;

        //整数受け取り
        string[] str = Console.ReadLine().Split(' ');
        r = int.Parse(str[0]);
        c = int.Parse(str[1]);

        //2次元配列数値受け取り
        int[,] array = new int[r, c];

        for (i = 0; i < r; i++)
        {
            string[] str2 = Console.ReadLine().Split(' ');

            for (j = 0; j < c; j++)
            {
                array[i, j] = int.Parse(str2[j]);
            }
        }

        //横配列計算
        for (i = 0; i < r; i++)
        {
            for (j = 0; j < c; j++)
            {
                subTotal += array[i, j];
                Console.Write(array[i, j] + " ");
            }
            Console.Write(subTotal);
            subTotal = 0;
            Console.WriteLine("");
        }

        //縦配列計算
        for (j = 0; j < c; j++)
        {
            for (i = 0; i < r; i++)
            {
                subTotal += array[i, j];
            }
            Console.Write(subTotal + " ");
            total += subTotal;
            subTotal = 0;
        }
        Console.WriteLine(total);
    }
}



Measured memory_bytes: 9228
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
typedef long long Int;

#define MOD 1000000007LL

Int fact[216000];

Int pow(Int a, Int p){
  if(p == 0)return 1;
  Int res = pow(a, p / 2);
  res *= res;res %= MOD;
  if(p % 2)res *= a;
  return res % MOD;
}

Int inv(Int x){
  return pow(x, MOD - 2);
}

Int C(Int n, Int k){
  Int res = fact[n];
  res *= inv(fact[k]);res %= MOD;
  res *= inv(fact[n-k]);res %= MOD;
  return res;
}

Int h, w, a, b;

int main(){
  for(int i = 0;i < 216000;i++){
    if(i == 0)fact[i] = 1;
    else fact[i] = fact[i-1] * i % MOD;
  }
  cin >> h >> w >> a >> b;
  Int res = C(h + w - 2, h - 1);
  for(int i = 0;i < b;i++){
    res -= C(h - a + i - 1, i) * C(a + w - i - 2, a - 1) % MOD;
    res %= MOD;
  }
  if(res < 0)res += MOD;
  cout << res << endl;return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

vector<vin> g;
int n,m;
int dp[110000];

int func(int v){
 if(dp[v]!=-1){
   return dp[v];
 }
  int ret=0;
  for(auto nv:g[v]){
    
    chmax(ret,func(nv)+1); 
  }
  return dp[v]=ret;
}

int main(){
  cin>>n>>m;
  g.resize(n,vin());
  
  rep(i,m){
   int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
  }
  /////////////nyuuryoku
  rep(i,n){
   dp[i]=-1; 
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,func(i));    
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 8192
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);int k=a[1],x=0;
	if(a[n]-k>1) return !printf("No\n");
	if(k==a[n]) return !printf("%s\n",(2*k<=n||k==n-1)?"Yes":"No");
	for(int i=1;i<=n;i++) if(a[i]==k) x++;
	if(x>k) return !printf("No\n");
	if(2*(k+1-x)<=n-x) return !printf("Yes\n");
	return !printf("No\n");
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define ROF(i, j, k) for(int i = j; i >= k; i--)
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define MP make_pair
#define LL long long
#define MOD 998244353
#define MX 200010
#define INFL 1000000000000000000LL
#define INF 1000000000

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;

int n;
LL ara[100010];
bool vis[110][110];
//int dp[110][110];
//
//int func(int pos, int nisi) {
//    if(pos == n) {
//        if(nisi) {
//            return -1000000000;
//        }
//        return 0;
//    }
//    if(vis[pos][nisi]) {
//        return dp[pos][nisi];
//    }
//    int ans = -1000000000;
//
////    /// na niye
////    ans = func(pos + 1, nisi);
//
//    /// mn hishebe niye
//    ans = max(ans, ara[pos] + func(pos + 1, nisi + 1));
//
//    /// mx hishebe niye
//    if(nisi) {
//        ans = max(ans, func(pos + 1, nisi - 1));
//    }
//    vis[pos][nisi] = 1;
//    return dp[pos][nisi] = ans;
//}

int main()  {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);tt
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    FastIO;

    cin >> n;
    n *= 2;
    FOR(i, 0, n - 1) {
        cin >> ara[i];
    }
    sort(ara, ara + n);
//    FOR(i, 0, n - 1) {
//        cout << ara[i] << " ";
//    }
//    cout << "\n";
    LL ans = 0;
//    for(int i = n - 2; i >= 0; i-= 2) {
//        ans += ara[i];
//    }

    for(int i = 0; i < n; i += 2) {
        ans += ara[i];
    }
    cout << ans << "\n";
//    cout << func(0, 0) << "\n";
    return 0;
}
/**
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    int s = 7;
    rep(i,K){
        if(s%K == 0){
            cout << i+1 << endl;
            return 0;
        }

        s %= K;
        s = s*10+7;        
    }
    cout << -1 << endl;
    

}



Measured memory_bytes: 3592
a=input()
b=a.split(" ")
c=list(map(int,b))
w=c[0]
h=c[1]
x=c[2]
y=c[3]
r=c[4]
if((x-r)<0 or (x+r)>w or (y-r)<0 or (y+r)>h):
    str="No"
else :
    str="Yes"
print(str)

Measured memory_bytes: 7672
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


N = int(input())
if N == 1:
    print(input())
else:
    t1 = int(input())
    t2 = int(input())
    t = lcm(t1, t2)
    for _ in range(2, N):
        t = lcm(t, int(input()))
    print(t)


Measured memory_bytes: 5432
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        ArrayList<Integer> A = new ArrayList<Integer>();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
 
        for(int i=0;i<N;i++){
            A.add(scanner.nextInt());
        }
        printList(A,N);
        insertionSort(A,N);
    }
     
    static void insertionSort(ArrayList<Integer> A,int N){
        for(int i=1;i<N;i++){
            int v = A.get(i);
            int j=i-1;
            while(j>=0 && (v < A.get(j))){
                A.set(j+1,A.get(j));
                j--;
            }
            A.set(j+1, v);
            printList(A,N);
        }
    }
    static void printList(ArrayList<Integer> A,int N){
        StringBuilder builder = new StringBuilder();
        for(int i=0;i<N;i++){
            if(i>0){
                builder.append(" ");
            }
            builder.append(A.get(i));
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 29956
package main

import (
	"fmt"
)

type ll int64


func main() {

	var N int
	fmt.Scan(&N)

	value := make([]int, N)
	cost := make([]int, N)

	for i := 0 ; i < N ; i++ {
		fmt.Scan(&value[i])
	}

	for i := 0 ; i < N ; i++ {
		fmt.Scan(&cost[i])
	}

	var ans = 0

	for i := 0 ; i < N ; i++ {
		if value[i] >= cost[i] {
			ans += value[i] - cost[i]
		}

	}

	fmt.Println(ans)

}


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

#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

const ll M=1e9+7,N=1e5;
ll A[N];

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

	ll n,res=0;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
			res += A[i]*A[j];
	}
	cout<<res<<"\n";

	return 0;
}

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

void solve(){
    int n,w;
    cin>>n>>w;
    vector<ll> dp(w+1,0);
    ll ans=0;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        for(int j=w-x;j>=0;j--){
            dp[j+x]=max(dp[j+x],dp[j]+y);
            ans=max(dp[j+x],ans);
        }
    }
    cout<<ans<<endl;
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 4028
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL MAXN = 200010;
const LL INF = 2147483600;

LL N,M;
LL Ad[MAXN+1],Adx[MAXN+1];
inline LL Gd(LL x,LL y){
	if(x<y) return y-x;
	else return M-(x-y);
} inline bool kua(LL x,LL y){
	return abs(x-y)>N+1-abs(x-y);
} inline void Add(LL x,LL y,LL Fir){
	Ad[x]+=Fir; Ad[y+1]-=(Fir+(y-x)); Adx[x+1]++; Adx[y+1]--;
} LL a[MAXN+1],dist[MAXN+1],ans;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),M=read();
	for(LL i=1;i<=N;i++) a[i]=read();
	for(LL i=2;i<=N;i++) dist[i]=Gd(a[i-1],a[i]);
	for(LL i=2;i<=N;i++){
		LL x=a[i-1],y=a[i];
		//if(x>y){ if(x<M) Add(x+1,M,0); Add(1,y,M-x);}
		//else { if(x<y) Add(x+1,y,0); }
		if(x<y&&y-x>=2) Add(x+2,y,1);
		if(x>y){
			if(x+2<=M) Add(x+2,M,1);
			if(M-x>=1) Add(1,y,M-x);
			else if(y>=2) Add(2,y,1);
		}
	} LL now=0,from=0;
	for(LL i=1;i<=M;i++){now+=Ad[i]; from+=Adx[i]; now+=from; ans=max(ans,now);}
	for(LL i=2;i<=N;i++) ans-=dist[i];
	printf("%lld\n",-ans);
	return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };

int m, n;

int main(void)
{
	string str;
	while(cin >> str && str != "")
	{
		for(auto c : str)
		{
			cout << (char)((c - 'A' - 3 % 26 + 26) % 26 + 'A');
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    string n;
    string m;
 
   cin >> n >> m;
  
  
   if(n[0]==m[2]&&m[0]==n[2]&&n[1]==m[1]){
     
     cout << "YES" << endl;
     
   }else{
     cout << "NO" << endl;
   }
  
   
  
  return 0;
}

Measured memory_bytes: 256
x = int(input())

div = set()
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        div.add(i)
        div.add(x//i)

div = list(div)

for d in div:
    for a in range(int(pow(x, 1/2))+1):
        b = a - d
        if a**5 - b**5 == x:
            print(a, b)
            break


Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    double p[n];
    rep (i, 0, n) cin >> p[i];
    double dp[n + 1][n + 1];
    // i枚まで操作して、j枚表のとき、表が裏より多くなる確率
    rep (i, 0, n + 1) rep (j, 0, n + 1) dp[i][j] = 0;
    dp[0][0] = 1;
    rep (i, 0, n) {
        rep (j, 0, n) {
            //配るDP
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    rep (i, n / 2 + 1, n + 1) {
        // cout << dp[n][i] << "\n";
        ans += dp[n][i];
    }
    cout << fixed << setprecision (15) << ans << "\n";
}

Measured memory_bytes: 70528
#include <stdio.h>

#define MAX 1000000

int prime[MAX];

void gen_prime(int n)
{
    int i, j;

    for (i = 0; i < n; ++i) {
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;

    for (i = 0; i * i <= n; ++i) {
        if (prime[i]) {
            for (j = 2 * i; j <= n; j += i) {
                prime[j] = 0;
            }
        }
    }
}

int main(void)
{
    int nprime[MAX] = {0};
    int i, n;

    gen_prime(MAX - 1);
    for (i = 1, n = 0; i < MAX; ++i) {
        if (prime[i]) {
            nprime[i] = ++n;
        }
    }

    while (scanf("%d", &n) != EOF) {
        if (n == 1) {
            printf("0\n");
        } else {
            while (nprime[n] == 0) {
                --n;
            }
            printf("%d\n", nprime[n]);
        }
    }

    return 0;
}

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

int main(void) {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M, 0));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }

  const int INF = 100000000;
  int ans = INF;
  for (int n = 0; n < (1 << N); n++) {
    int c = 0;
    vector<int> a(N, 0);
    for (int i = 0; i < N; i++) {
      if ((n >> i) & 1) {
        c += C[i];
        for (int j = 0; j < M; j++)
          a[j] += A[i][j];
      }
    }
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (a[j] < X)
        flag = false;
    }
    if (flag)
      ans = min(ans, c);
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;++i){
    cin >> a[i] >> b[i];
  }
  
  int num[N] = {0};
  for(int i=0;i<M; ++i){
    num[a[i]-1]++;
    num[b[i]-1]++;
  }
  for(int i=0;i<N;++i){
    cout << num[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; i++)
#define REP(i, n) for (int i=1; i<n; i++)
using namespace std;
using f=float; using ll=long long; using ld=long double;
using ull=unsigned long long; using vi=vector<int>; using pii=pair<int, int>;

int gcd(int a, int b) {
    int t;
    while ( b != 0 ) {
        t = a%b; a = b; b = t;
    }
    return a;
}

int main() {
    int n;
    ll sum = 0;
    cin >> n;
    REP(i, n+1) if ( gcd(i, 3) == 1 and gcd(i, 5)==1 ) sum += i;
//            if ( i < 100) cout << i << " " << sum << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
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 X = sc.nextInt();
    int c[] = new int[N];
    int a[][] = new int[N][M];
    
    for(int i = 0 ; i < N ; ++i){
      c[i] = sc.nextInt();
      for(int j = 0 ; j < M ; ++j){
        a[i][j] = sc.nextInt();
      }
    }
    int ans = 1000000000;
    
    for(int i = 1 ; i < (1<<N) ; ++i){
      int k[] = new int[M];
      int l = 0;
      for(int j = 0 ; j < N ; ++j){
        if((1&(i>>j))==1){
          l += c[j];
          for(int o = 0 ; o < M ; ++o){
            k[o] += a[j][o];
          }
        }
      }
      for(int j = 0 ; j < M ; ++j){
        if(k[j] < X) break;
        if(j == M-1) ans = Math.min(ans,l);
      }
    }
    if(ans == 1000000000) System.out.println(-1);
    else System.out.println(ans);
    
  }
}


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

int main() {
  int N, n;
  cin >> N;
  for(int i = 1; i < N + 1; i++) {
    if(i / 10 == 0) {
      n++;
    }
    else if(i / 1000 == 0 && i / 100 != 0) {
      n++;
    }
    else if(i / 100000 == 0 && i / 10000 != 0) {
      n++;
    }
  }
  cout << n << endl;
}

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

#define int long long
#define MAX 1000000
#define INF 1000000000
#define pb push_back
#define F first
#define S second

signed main(){
    int K, X;
    cin>>K>>X;
    for(int i=X-K+1; i<X; i++){
        cout<<i<<" ";
    }
    for(int i=X; i<K+X; i++){
        cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int n,y;
  cin >> n >> y;
  bool f = false;
  for(int i = 0;i <= n;i++){
    for(int j = 0;j <= n-i;j++){
      ll a = i*10000+j*5000+(n-i-j)*1000;
      if(a == y){
	cout << i << " " << j << " " << n-i-j << endl;
	f = true;
	break;
      }
    }
    if(f == true)
      break;
  }
  if(f == false)
    cout  << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
ans = "DENIED"
for i in range(0, N):
    if A[i] % 2 == 0 and A[i] % 3 != 0 and A[i] % 5 != 0:
        print("DENIED")
        exit(0)
print("APPROVED")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

bool is_mid(int& a, int& b, int& c) {
  if (a < b && b < c) {
    return true;
  } else if (c < b && b < a) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i, N) cin >> p[i];
  int answer {};
  srep(i, 1, N-1) {
    if (is_mid(p[i-1], p[i], p[i+1])) ++answer;
  }
  cout << answer << '\n';
}


Measured memory_bytes: 888