akhauriyash/Code-Regression huggingface dataset:
A = [input().split() for _ in range(3)]
N = int(input())

C = [[False] * 3 for _ in range(3)]

for _ in range(N):
    b = input()
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                C[i][j] = True

ans = False
for i in range(3):
    ans |= C[i][0] and C[i][1] and C[i][2]
for j in range(3):
    ans |= C[0][j] and C[1][j] and C[2][j]

ans |= C[0][0] and C[1][1] and C[2][2]
ans |= C[2][0] and C[1][1] and C[0][2]

print('Yes' if ans else 'No')



Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;

    return 0;
}


Measured memory_bytes: 3524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		if(a < c && c < b) {
			System.out.println("Yes");
			return;
		}
		
		if(b < c && c < a) {
			System.out.println("Yes");
			return;
		}
		
		System.out.println("No");
		return;
		
	}

}


Measured memory_bytes: 23252
# include<stdio.h>

int main(){
    int n,m;
    scanf ( "%d %d",&n,&m );
    int r[m][2];
    for ( int i = 0;i < m;i++ )
        scanf ( "%d %d",&r[i][0],&r[i][1] );
    int c[n+1];
    for ( int i = 0;i < n+1;i++ )
        c[i]=0;
    for ( int i = 0;i < m;i++ ){
        c[r[i][0]]++;
        c[r[i][1]]++;
    }
    for ( int i = 1;i < n+1;i++ )
        printf ( "%d\n",c[i] );
}


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

#define MP make_pair 
#define N 200005
typedef long long LL;
const int mod = 1e9 +7;

char s[N];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int n;
	scanf("%s", s+1);
	n = strlen(s+1);
	LL ans = 0;
	int cnt = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (s[i] == 'A') ++cnt;
		else if (s[i] == 'C') cnt = 0;
		else 
		{
			if (s[i+1] == 'C') ans += cnt, ++i;
			else cnt = 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E;
  cin>>A>>B>>C>>D>>E;
  if(A==0){
    A=1;
    cout<<A;
  }
   if(B==0){
    B=2;
    cout<<B; 
  }
   if(C==0){
    C=3;
    cout<<C;
  }
  if(D==0){
    D=4;
    cout<<D;
  }
   if(E==0){
     E=5;
     cout<<E;
   }

  





}





Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }
  int l = 1, r = *max_element(a.begin(), a.end());
  while (l < r) {
    int64_t m = (l + r) >> 1;
    int64_t tmp = 0;
    for (int x : a) {
      tmp += (x + m - 1) / m - 1;
    }
    if (tmp > k) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  cout << r << endl;
  return 0;
}



Measured memory_bytes: 3996
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        h: usize, w: usize, k: usize,
        ccc: [Chars; h],
    }
    let mut board = vec![vec![0i64; h*2]; w];
    for y in (0..h).rev() {
        for x in 0..w {
            let c = ccc[y][x].to_digit(10).unwrap() as i64;
            board[x][h-y-1] = c;
        }
    }

    let mut ans = 0i64;
    for sy in 0..h {
        for sx in 0..w {
            let mut board = board.clone();
            let mut total = 0i64;
            board[sx].remove(sy);

            let mut ratio = 1i64;
            while let Some(score) = cease(&mut board, k, h, w) {
                total += ratio * score;
                ratio *= 2;
            }
            ans = max(ans, total);
        }
    }

    println!("{}", ans);
}

fn cease(board: &mut Vec<Vec::<i64>>, k: usize, h: usize, w: usize) -> Option<i64> {
    let mut dels = Vec::new();
    for y in 0..h {
        let mut start = 0;
        let mut number = 1;
        for x in 0..w {
            if board[x][y] != number {
                if x - start >= k && number != 0 {
                    for i in start..x {
                        dels.push((i, y, number));
                    }
                }
                start = x;
                number = board[x][y];
            } else if x == w-1 {
                if x + 1 - start >= k && number != 0 {
                    for i in start..=x {
                        dels.push((i, y, number));
                    }
                }
            }
        }
    }
    let mut score = 0;
    while let Some((x, y, number)) = dels.pop() {
        board[x].remove(y);
        score += number;
    }
    if score == 0 {
        None
    } else {
        Some(score)
    }
}

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

int main () {
    int N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        int s, t;
        cin >> s >> t;
        sum += t - s + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;

    getline(cin, str);

    for (int i = 0; i < str.length(); i++)
    {
        if (str[i] >= 'A' && str[i] <= 'Z')
        {
            str[i] = str[i] - 'A' + 'a';
        }
        else if (str[i] >= 'a' && str[i] <= 'z')
        {
            str[i] = str[i] - 'a' + 'A';
        }
        else
        {
            str[i] = str[i];
        }
    }
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 1176
defmodule Main do
  def main do
    x =
      IO.read(:line)
      |> String.trim |> String.to_integer
    if rem(x, 1000) == 0 do
    	IO.puts(0)
        else
    		IO.puts(1000 - rem(x, 1000))
            end
  end
end


Measured memory_bytes: 30608
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var alist = nextIntArray();
  var blist = nextIntArray();
  var clist = nextIntArray();
  var output = 0;
  var maeIndex = -1;
  for(var i = 0; i < N; i++){
    output += blist[alist[i] - 1];
    if(maeIndex + 1 == alist[i] - 1 && maeIndex != -1){
      output += clist[maeIndex];
    }
    maeIndex = alist[i] - 1;
  }
  myout(output);
}

Measured memory_bytes: 30168
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int64_t solve(int64_t n, const string & s) {
    int64_t r = count(ALL(s), 'R');
    int64_t g = count(ALL(s), 'G');
    int64_t b = count(ALL(s), 'B');
    int64_t cnt = 0;
    REP (i, n) {
        REP3 (j, i + 1, n) if (s[j] != s[i]) {
            int k = j + (j - i);
            if (k >= n) break;
            if (s[k] != s[i] and s[k] != s[j]) {
                ++ cnt;
            }
        }
    }
    return r * g * b - cnt;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t N;
    string S;
    cin >> N >> S;
    auto ans = solve(N, S);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool d[100*100*11*11*4];

int main(){
  int n,m,a;
  cin>>n>>m>>a;
  vector<string> vec(n);
  rep(i,n) cin>>vec[i];

  // pos[i][j], left a[x][y], direction d
  auto f = [&](int i, int j, int x, int y, int dir){
    return (((i*m+j)*(a+1)+x)*(a+1)+y)*4+dir;
  };

  int sx,sy,tx,ty;
  rep(i,n)rep(j,m){
    if(vec[i][j]=='S'){
      if(i+1==n || vec[i+1][j]=='#'){
        cout << -1 << endl;
        return 0;
      }
      sx = i+1; sy = j;
    }
    if(vec[i][j]=='G') tx=i, ty=j;
  }

  auto ok = [&](int i, int j, int dir){//dbg(i,j,dir);
    if(i<0 || i>=n || j<0 || j>=m) return false;
    if(dir%2==0 && vec[i][j]=='S') return false;
    return (vec[i][j]=='.' || vec[i][j]=='G' || vec[i][j]=='S' );
  };

  const int dx[] = {1,0,-1,0};
  const int dy[] = {0,1,0,-1};
  const int mirrx[] = {3,2,1,0};
  const int mirry[] = {1,0,3,2};

  int res = INF;

  fill(d, d+(sizeof(d)), false);
  queue<int> qx, qy, qi, qj, qd;
  d[f(sx,sy,0,0,0)] = true;
  qx.push(sx); qy.push(sy); qi.push(0); qj.push(0); qd.push(0);

  while(!qx.empty()){
    int x = qx.front(); qx.pop();
    int y = qy.front(); qy.pop();
    int i = qi.front(); qi.pop();
    int j = qj.front(); qj.pop();
    int dir = qd.front(); qd.pop();

    if(x==tx && y==ty){
      res = min(res, i+j);
      continue;
    }

    int nx,ny;

    // ????????????
    nx = x + dx[dir];
    ny = y + dy[dir];
    if(ok(nx, ny, dir)){
      int z = f(nx, ny, i, j, dir);
      if(!d[z]){
        d[z] = true;
        qx.push(nx); qy.push(ny); qi.push(i); qj.push(j); qd.push(dir);
      }
    }

    if(vec[x][y]=='S') continue;

    // mirror
    nx = x + dx[mirrx[dir]];
    ny = y + dy[mirrx[dir]];
    if(i<a && ok(nx, ny, mirrx[dir])){
      int z = f(nx, ny, i+1, j, mirrx[dir]);
      if(!d[z]){
        d[z] = true;
        qx.push(nx); qy.push(ny); qi.push(i+1); qj.push(j); qd.push(mirrx[dir]);
      }
    }

    nx = x + dx[mirry[dir]];
    ny = y + dy[mirry[dir]];
    if(j<a && ok(nx, ny, mirry[dir])){
      int z = f(nx, ny, i, j+1, mirry[dir]);
      if(!d[z]){
        d[z] = true;
        qx.push(nx); qy.push(ny); qi.push(i); qj.push(j+1); qd.push(mirry[dir]);
      }
    }
  }

  if(res<=2*a) cout << res << endl;
  else cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 7996
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
int n;
vector<int> g[maxn],lsh;
int a[maxn],ans[maxn],rec[maxn],pre[maxn];
vector<int> f[maxn],h;
void solve(int x,int fa)
{
	int pos=lower_bound(h.begin(),h.end(),a[x])-h.begin();
	f[pos].push_back(a[x]);
	h[pos]=a[x];
	rec[x]=pos;
	ans[x]=lower_bound(h.begin(),h.end(),inf)-h.begin();
	
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i];
		if(to==fa)continue;
		solve(to,x);
	}
	
	f[pos].pop_back();
	h[pos]=f[pos].back();
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		lsh.push_back(a[i]);
	}
	sort(lsh.begin(),lsh.end());
	lsh.erase(unique(lsh.begin(),lsh.end()),lsh.end());
	for(int i=0;i<n;i++)
	{
		a[i]=lower_bound(lsh.begin(),lsh.end(),a[i])-lsh.begin();
	}
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		u--,v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	f[0].push_back(-1);
	h.push_back(-1);
	for(int i=1;i<=n+1;i++)
	{
		f[i].push_back(inf);
		h.push_back(inf);
	}
	solve(0,-1);
	for(int i=0;i<n;i++)
	{
		printf("%d\n",ans[i]-1);
	}
	return 0;
}

Measured memory_bytes: 44480
//https://atcoder.jp/contests/agc038/tasks/agc038_a
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
using namespace std;
int main()
{
    int n,k;string s;
    cin>>n>>k;cin>>s;
    int ans=0;
    for(int i=1;i<n;i++) if(s[i]==s[i-1]) ans++;
    cout<<min(ans+2*k,n-1);
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 100;
ll a[N], b[N], c[N];
ll l[N], r[N];
ll n;

int main()
{
   // freopen("in.txt","r",stdin);
    memset(l, 0, sizeof(l));
    memset(r, 0, sizeof(r));
    cin>>n;
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    for(int i=0;i<n;i++)scanf("%lld",&b[i]);
    for(int i=0;i<n;i++)scanf("%lld",&c[i]);
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    ll i, j = n - 1;
    ll ans1 = 0, ans2 = 0, s = n * n * n, d = 0;
    for(i = n - 1;i>=0;i--) {
        for(;j>=-1;j--) {
            if(j == -1 || a[i] >= b[j])break;
        }
        ans1 += (j + 1) * n;
        if(j >= 0)l[j] ++;
    }
    for(i = n - 1;i>=0;i--) {
        d += l[i];
        l[i] = d;
    }

    j = n - 1;
    for(i = n - 1;i>=0;i--) {
        for(;j>=-1;j--) {
            if(j == -1 || b[i] >= c[j])break;
        }
        ans2 += (j + 1) * n;
        r[i] = j + 1;
    }

    ll ret = s - ans1 - ans2;
    for(i=0;i<n;i++) {
        ret += l[i] * r[i];
    }
    cout<<ret<<endl;
    return 0;
}


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

int level(double v){
    return v >= 1.1 ? 0 : (v >= 0.6 ? 1 : (v >= 0.2 ? 2 : 3));
}

int main(){
    int la[4], ra[4];
    double l, r;
    fill(la, la+4, 0);
    fill(ra, ra+4, 0);
    while(scanf("%lf%lf", &l, &r) != EOF){
        la[ level(l) ]++;
        ra[ level(r) ]++;
    }
    for(int x = 0; x < 4; x++) printf("%d %d\n", la[x], ra[x]);
    return 0;
}

Measured memory_bytes: 1056
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int selectionSort(vector<int> &A) {
  int swapcount = 0;

  for (size_t i = 0; i < A.size() - 1; i++) {
    size_t minj = i;
    for (size_t j = i + 1; j < A.size(); j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    if (minj != i) {
      // cout << "swap " << nums[i] << " and " << nums[minj] << endl;
      int tmp = A[minj];
      A[minj] = A[i];
      A[i] = tmp;
      swapcount++;
    }
  }

  return swapcount;
}

void printVector(vector<int> v) {
  for (size_t i = 0; i < v.size(); i++) {
    if (i > 0) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

int main(int argc, char **argv) {
  vector<int> nums;

  size_t N;
  cin >> N;

  for (size_t i = 0; i < N; i++) {
    int ti;
    cin >> ti;
    nums.push_back(ti);
  }
  // printVector(nums);

  int swapcount = selectionSort(nums);

  printVector(nums);
  cout << swapcount << endl;

  return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  
  int n; cin >> n;
  std::vector<int> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  std::sort(l.begin(), l.end()); 
  
  int ans = 0;
  for(int i = 0; i < n; i++)
  {
    for(int j = i+1; j < n; j++)
    {
      int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));
      
      ans += std::max(k-(j+1),0);
    }
  }
  std::cout << ans << std::endl;
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
int main()
{
    ull x;

    long double y;

    cin>>x>>y;

    ull sum=0;

    y=round(y*100);

    sum=x*y;

    cout<<sum/100<<endl;




}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll MOD=1e9+7;
///modulo version
ll binpow(ll a,ll b) {
if (b == 0)return 1;ll res = binpow(a, b / 2)%MOD;
if (b % 2)return ((res%MOD * res%MOD)%MOD * a%MOD)%MOD;else return (res%MOD * res%MOD)%MOD;}

ll inv(ll A)
{
    return binpow(A,MOD-2);
}

//modulo arithmetic
inline ll add(ll a, ll b)
{
	ll res = a + b;
	if(res >= MOD)
		return res - MOD;
	return res;
}

inline ll mult(ll a, ll b)
{
	ll  res = a;
	res *= b;
	if(res >= MOD)
		return res % MOD;
	return res;
}

inline ll sub(ll a, ll b)
{
	return (a%MOD-b%MOD+MOD)%MOD;
}
ll ncr(ll n,ll r)
{
	ll ans=1LL;
	ll mini = min(r, (n - r));//minimum of r,n-r
	ll x=1LL;
	ll mx = max(r,(n-r));
	//cerr<<mini<<endl;
	for(ll i=1;i<=mini;i++)
	{
		ans=mult(ans,inv(i));
	}
    for (ll i = n;i > mx;i--) {
        ans =mult(mult(ans , i) ,inv(x));
    }
    return ans;
}

int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=sub(binpow(2,n),1LL);
	//cout<<ans<<endl;
	///nCa
	ans=sub(ans,add(ncr(n,a),ncr(n,b)));
	cout<<ans<<endl;
    return 0;
}

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

struct st {
	double x, y;
} a[105];
int n;
double x, y, ans;

bool cmp(st p, st q) {
	return atan2(p.y, p.x) < atan2(q.y, q.x);
}

int main() {
	int i, j, c;
	cin >> n;
	for(i=0; i<n; i++) cin >> a[i].x >> a[i].y;
	sort(a, a+n, cmp);
	for(i=0; i<n; i++) {
		x=0.0, y=0.0;
		for(j=i, c=0; c<n; j++, c++) {
			x += a[j%n].x;
			y += a[j%n].y;
			ans = max(ans, sqrt(x*x + y*y));
		}
	}
	printf("%.15f", ans);
	return 0;
}

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

int main()
{
  int N,A;
  cin>>N;
  cin>>A;
  if(1<=N<=10000&&0<=A<=1000)
    {
      if(N%500<=A)
	{
	  cout<<"Yes"<<endl;    
	}
      else
	{
	  cout<<"No"<<endl;
	}      
    }
  
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if (n > 2 and m > 2)
        print((n - 2) * (m - 2));
    else if (n == 1 and m == 1)
        print(1);
    else if (n == 1)
        print(max(m - 2, 0LL));
    else
        print(max(n - 2, 0LL));

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define Nmax 110000
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
int memo[Nmax];

int dp(int n) {
    if (memo[n] != -1) return memo[n];
    if (n == 0) return 0;
    int ans = 100000000;
    for (int n6 = 1; n6 <= n; n6 *= 6) {
        ans = MIN(ans, 1 + dp(n - n6));
    }
    for (int n9 = 1; n9 <= n; n9 *= 9) {
        ans = MIN(ans, 1 + dp(n - n9));
    }
    return memo[n] = ans;
}

int main() {
    int N;
    scanf("%d",&N);  
    for (int i=0; i<Nmax; i++) memo[i] = -1;
    printf("%d", dp(N));
}




Measured memory_bytes: 5248
import math
l = []
n = int(input())
for i in range(2,int(math.sqrt(n))+1):
  flg = 0
  while n % i == 0:
    if flg == 0:
      l.append(1)
      flg = 1
    else:
      l[-1] += 1
    n = n//i

if n != 1:
  l.append(1)

ans = 0
for i in range(len(l)):
  c = 1
  while l[i] - c >= 0:
    l[i] -= c
    c += 1
    ans += 1

print(ans)


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

int main() {
  int N;
  cin >> N;
  
  int count = 0;
  
  for (int i = 1; i <= N; i++) {
    if (i >= 1 && i <= 9) {
      count++;
    } else if (i >= 100 && i <= 999) {
      count++;
    } else if (i >= 10000 && i <= 99999) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
N, T = tuple(int(i) for i in input().split())
ct = [tuple(int(i) for i in input().split()) for i in range(N)]

ct.append((1001, 1))
a = min([c for c, t in ct if T >= t])
if a != 1001:
    print(a)
else:
    print("TLE")


Measured memory_bytes: 2940
from itertools import product as p
c = [list(map(int, input().split())) for _ in range(3)]
 
a = [-1]*3
a[0] = 0
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]
 
for i, j in p(range(3), range(3)):
    if c[i][j] != a[i] + b[j]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations


def main():
    input = sys.stdin.readline
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))

    INF = 10**9
    A = [[INF for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        A[a-1][b-1] = c
        A[b-1][a-1] = c

    D = np.array(A, dtype=int)
    G = floyd_warshall(D)

    """
    ans = INF
    for start in r[:2]:
        passed = [start]
        temp_ans = 0
        while len(passed) < len(r):
            cur = INF
            next_start = -1
            for dest in r:
                if dest in passed:
                    continue

                if A[start-1][dest-1] < cur:
                    next_start = dest
                    cur = A[start-1][dest-1]

            passed.append(next_start)
            start = next_start
            temp_ans += cur

        ans = min(ans, temp_ans)
    """

    ans = INF
    for root in permutations(r):
        cur = 0
        for i in range(R-1):
            s, g = root[i] -1, root[i+1] - 1
            cur += G[s][g]

        ans = min(ans, cur)

    return int(ans)


if __name__ == '__main__':
    print(main())


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

namespace ABC070B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            var begin = Math.Max(nums[0], nums[2]);
            var end = Math.Min(nums[1], nums[3]);

            var time = end - begin;

            if (time < 0)
            {
                time = 0;
            }

            Console.WriteLine(time);

        }
    }
}


Measured memory_bytes: 11220
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = list(range(1, 100))

if n ==0:
    print(x)
else:
    for j in range(51):
        ll = []
        if not x-j in p:
            ll.append(x-j)
        if len(ll) != 0:
            print(min(ll))
            break
        if not x+j in p:
            ll.append(x+j)
        if len(ll) != 0:
            print(min(ll))
            break


Measured memory_bytes: 61968
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	a := nextInt()

	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}


Measured memory_bytes: 640
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int fiveCount = search(str,'5');
        int sevenCount = search(str,'7');
        if(fiveCount == 2 && sevenCount == 1){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }

    static int search(String str, char target){
        int count = 0;
        for(char x: str.toCharArray()){
            if(x == target){
                count++;
            }
        }
        return count;
    }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m,a,ans;
priority_queue<int> pq;

signed main() {
    cin >> n >> m;
    rep(i,n) {
        cin >> a;
        pq.push(a);
    }
    rep(i,m) {
        int tmp = pq.top();pq.pop();
        pq.push(tmp/2);
    }
    while(pq.size()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;


ll dp[2][100005];

int main(void){
  ll n, c;
  cin >> n >> c;
  vector<ll> x(n+2), v(n+2);
  x[0] = v[0] = v[n+1] = 0;
  x[n+1] = c;
  REP(i, n) cin >> x[i+1] >> v[i+1];

  ll cal = 0;
  REP(i, n){
    cal += v[i+1];
    cal -= x[i+1] - x[i];
    dp[0][i+1] = max(dp[0][i], cal);
  }

  cal = 0;
  REPr(i, n){
    cal += v[i+1];
    cal -= x[i+2] - x[i+1];
    dp[1][i+1] = max(dp[1][i+2], cal);
  }

  ll ans = 0;
  REP(i, n+1){
    chmax(ans, max(dp[0][i]+dp[1][i+1]-x[i], dp[0][i]+dp[1][i+1]-c+x[i+1]));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int B = S.size();
    int i = 0;
    while(i < B){
      if(S[i] != T[i]){
        cout << "No" << endl;
        break;
      }
      if(i == B - 1){
        cout << "Yes" << endl;
       break;
    }
      i++;
    }
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    int num,check=7,count,temp;
    while(cin>>num,num>=100 && num<1000)
    {
        count=0;
        while(num>0)
        {
        temp=num%10;
            if(temp==check)
            {
                count++;
                if(count!=0)
                {
                cout<<"Yes"<<endl;
                }
                break;
            }
            num/=10;
        }
        if(count==0)
        {
            cout<<"No"<<endl;
            break;
        }
      break;
    }
}

Measured memory_bytes: 3636
S=gets.chomp
values=S.split(//)
a,b,c,d=0,0,0,0
for str2 in values[2..-2]
    b+=1
    if str2=="C"
        a+=1
        values.delete_at(b+1)
        break
    end
end
if values[0]=="A"
    values.delete_at(0)
    c+=1
end
for str3 in values
    if str3<="Z"
        d+=1
        break
    end
end
if a==1 and c==1 and d==0
    puts "AC".to_s
else
    puts "WA".to_s
end

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

using namespace std;
int n,h[100000],dp[100000];
int main()
{
    cin >>n;
    for (int i=0;i<n;i++)
        cin >>h[i];
    dp[1]=abs(h[1]-h[0]);
    for (int i=2;i<n;i++)
    {
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout <<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<vector<int>> tree;
vector<int> dist;

void dfs(int v, int p, int d){
	dist[v] = d;
	for(auto nv : tree[v]){
		if(nv == p) continue;
		dfs(nv, v, d+1);
	}
}

vector<int> calcDist(int s){
	dist = vector<int>(n);
	dfs(s, -1, 0);
	return dist;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	tree.resize(n);
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	vector<int> distF = calcDist(0);
	vector<int> distS = calcDist(n-1);
	int F = 0, S = 0;
	rep(i,n){
		if(distF[i] <= distS[i]) F++;
		else S++;
	}
	if(F > S) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 11648
input = raw_input

a_dict = {}
for i in range(3):
    a_line = map(int, input().split(" "))
    for j in range(3):
        a = a_line[j]
        a_dict[a] = (i, j)

n = int(input())
taishos = a_dict.keys()

attas = [[False, False, False] for _ in range(3)]
for _ in range(n):
    b = int(input())
    if b in taishos:
        i, j = a_dict[b]
        attas[i][j] = True

found = False

for i in range(3):
    for j in range(3):
        atta = attas[i][j]
        if not atta:
            break
        
        if j == 2:
            found = True

if not found:
    for j in range(3):
        for i in range(3):
            atta = attas[i][j]
            if not atta:
                break
            
            if i == 2:
                found = True

if not found:
    flag = attas[0][0] * attas[1][1] * attas[2][2] + attas[2][0] * attas[1][1] * attas[0][2]
    if flag >= 1:
        found = True

if found:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 28652
#include<stdio.h>

#define N 2000
#define A 101
#define NIL -1

void Prim();

static const int MAX=500;
static const int INFTY=(1<<21);

int M[A][A], p[A], S[A], d[A], n;

main(){
  int i, j, u, k, v, c;
  scanf("%d", &n);
  for (i=0; i<n; i++)
    for (j=0; j<n; j++){
      M[i][j]=INFTY;
    }
  
  for (i=0; i<n; i++){
    scanf("%d %d", &u, &k);
    for (j=0; j<k; j++){
      scanf("%d %d", &v, &c);
      M[u][v]=c;
    }
  }
  Prim();
  for (i=0; i<n; i++) printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  
  return 0;
}

void Prim(){
  int i, v, u, k[A];
  for(u=0;u<n;u++){
    k[u]=INFTY;
    p[u]=NIL;
    d[u]=INFTY;
  }
  
  k[0]=0;
  
  while(1){
    int minv=INFTY;
    u=NIL;
    for(i=0; i<n; i++)
      if(k[i]<minv && p[i]==NIL){
	u=i;
	minv=k[i];
      }
    
    if(u==NIL) break;
    p[u]=1;
    d[u]=k[u];
    for(v=0;v<n;v++) if(p[v]!=1 && k[u]+M[u][v]<k[v]) k[v]=k[u]+M[u][v];
  }
}

Measured memory_bytes: 640
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
K = int(input())
A = B = C = [i for i in range(1, K+1)]

L = [gcd(a,b) for a in A for b in B]

cnt = sum([gcd(l,c) for l in L for c in C])   
print(cnt)

Measured memory_bytes: 71724
from collections import defaultdict

n, m = map(int, input().split())
h = dict(enumerate(list(map(int, input().split()))))
ways = defaultdict(list)
for _ in range(m):
    fr, to = map(int, input().split())
    ways[fr].append(to)
    ways[to].append(fr)

total = 0
for i in range(1, n+1):
    if ways.get(i):
        to = set(ways.get(i))
        max_h = max([h[el-1] for el in to])
        if h[i-1] - max_h > 0:
            total += 1
    else:
        total += 1
        continue
    
print(total)

Measured memory_bytes: 40984
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;


int main()
{
   ll n;
   cin>>n;
   ll mod=1e9+7;
   if(n<2)cout<<0<<endl;
   else
   {
       ll ans=1;
       ll one=1;
       ll two=1;
       fr(i,0,n)
       {
           ans=(ans%mod * (10)%mod)%mod;
           one=(one%mod * (9)%mod)%mod;
           two=(two%mod * (8)%mod)%mod;

       }

       //one=(one*2)%mod;
       ans=(ans-one)%mod;
       ans=(ans-one)%mod;
       ans=(ans+two)%mod;

    if(ans<0)ans+=mod;



       cout<<ans<<endl;

   }


}




























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

int main(){
	string A, B;
	cin >> A >> B;
	int x=A.size(), y=B.size();
	if(x>y) cout << "GREATER";
	else if(x<y) cout << "LESS";
	else if(A>B) cout << "GREATER";
	else if(A<B) cout << "LESS";
	else cout << "EQUAL";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string.h>
using namespace std;

#define HUNDRED 100
#define THOUSAND 10000
#define TENTHOUSAND 10000
#define HUNDREDTHOUSAND 100000

int main() {
	string s;
	string t;

	cin >> s;

	t = s;

	for (int i = 0; s[i] != '\0'; i++) {
		for (int j = 0; t[j] != '\0'; j++) {
			if ((i == j) || (s[i] != s[j])) {
				continue;
			} else {
				cout << "no";
				exit(0);
			}
		}
	}

	cout << "yes";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

void solve() {
    int n, d; cin >> n >> d;
    cout << (n + 2*d)/(2*d+1);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && b == c)
    cout << 1 << endl;
  else if(a == b)
    cout << 2 << endl;
  else if(b == c)
    cout << 2 << endl;
  else if(a == c)
    cout << 2 << endl;
  else
    cout << 3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{

  string s;
  string t;
  cin >> s;
  cin >> t;
  int snum = s.size();
  int tnum = t.size();


  int lastSubPos = -1;
  bool isIncludeSubstringT = false;

  for (int i = 0; i <= snum - tnum; i++) {
    cerr << "startPos: " << i << "  s[i]: " << s[i] << endl;

    bool isSubstringofS = true;
    int pos = 0;
    for (int j = 0; j < tnum; ++j) {
      cerr << "j:" << j << endl;
      if (s[i + j] == t[j] || s[i + j] == '?') {

      } else {
        isSubstringofS = false;
        pos  = i + j;
        break;
      }
    }


    if (!isSubstringofS) {
      i = pos;
    } else {
      isIncludeSubstringT = true;
      lastSubPos = i;
    }
  }


  cerr << isIncludeSubstringT << endl;
  cerr << "lastpos:" << lastSubPos << endl;

  string ans = "";
  if (isIncludeSubstringT) {
    for (int i = 0; i < snum; ++i) {
      if (i >=  lastSubPos && i < lastSubPos + tnum) {
        ans += t[i - lastSubPos];
        cerr << "t:" << t[i - lastSubPos] <<endl;
      } else {
        if (s[i] == '?') {
          ans += 'a';
        } else {
          ans += s[i];
        }
      }

    }
  } else {
    ans = "UNRESTORABLE";
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
S = [list(raw_input()) for _ in range(3)]
t, p, d = 0, [0, 0, 0], {'a':0, 'b':1, 'c':2}
while True:
    try:
        p[t] += 1
        t = d[S[t][p[t]-1]]
    except:
        print ['A', 'B', 'C'][t]
        break

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int N; cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d[i];
  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

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

int end(){
    cout << 0 << endl;
    return 0 ;
}

ll const mod = 1e9+7 ;

int main(){
    int n ;
    cin >> n ;
    ll ans = 1 ;
    map<int,int> mp ;
    rep(i,n){
        int a ;
        cin >> a ;
        mp[a]++ ;
    }
    if(n%2 == 1){
        if(mp[0]!=1){ end(); return 0 ;}
        rep(i,n/2) if(mp[2*(i+1)]!=2){ end(); return 0 ;}
        rep(i,n/2){
            ans = 2*ans%mod ;
        }
        cout << ans << endl;
    }
        if(n%2 == 0){
        if(mp[0]!=0){ end(); return 0 ;}
        rep(i,n/2)if(mp[2*i+1]!=2){ end(); return 0 ;}
        rep(i,n/2){
            ans = 2*ans%mod ;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3200
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	ll N;
	cin >> N;
	vector<ll> h(N);
	rep(i, N) cin >> h[i];

	vector<ll> costs(N);
	costs[0] = 0;
	costs[1] = abs(h[1] - h[0]);
	for (ll i = 2; i < N; i++) {
		if (abs(h[i] - h[i - 2]) + +costs[i - 2] > abs(h[i] - h[i - 1]) + costs[i - 1]) {
			costs[i] = abs(h[i] - h[i - 1]) + costs[i - 1];
		}
		else {
			costs[i] = abs(h[i] - h[i - 2]) + costs[i - 2];
		}
	}

	cout << costs[N - 1] << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


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

int main(){
    int n,check=1,ans=0;
    cin >> n;
    int  A[n];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    for(int i=0;i<n;i++){
        if(A[i]==check){
            check++;
            continue;
        }else{
            ans++;
        }
    }
    if(ans==n){
        ans=-1;
    }
    cout << ans << endl;
    return 0;
 
}


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

int main() {
  int N,M;
  ll K;
  cin >>N>>M>>K;
  vector<int> adesk(N+1);
  vector<ll> bdesk(M+1);
  ll sumb=0;
  ll suma=0;
  int ans=0;
  
  rep(i,N){
    cin>>adesk.at(i+1);
  }
  rep(i,M){
    int b;
    cin>>b;
    sumb+=b;
    bdesk.at(i+1)=sumb;
  }
  
  rep(i,N+1){
    suma+=adesk.at(i);
    int left = -1, right = M+1;
    if(suma>K) break;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (bdesk.at(mid) <= (K-suma)) left = mid;
        else right = mid;
    }
    ans=max(ans,i+left);
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    string s;
    cin >> s;
    rep(i,s.size()-1){
        if(s[i]==s[i+1]) {cout << "Bad" <<endl; return 0;}
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstring>
#include<utility>
using namespace std;

/*
二次元格子上の幅優先探索。
点(gx,gy)への最小のコストはmin_cost[gx][gy]
startは点(sx,sy)
計算量O(WH)
*/
int h, w;
char grid[500][500];
int min_cost[500][500];

int bfs(int sx, int sy, int gx, int gy) {
	const int vx[] = { 0, 1, 0, -1 }, vy[] = { 1, 0, -1, 0 };
	memset(min_cost, -1, sizeof(min_cost));//min_costの初期化

	queue<pair<int, int>>que;
	que.emplace(sx, sy);
	min_cost[sx][sy] = 0;
	if (grid[sx][sy] == '#')return -1;
	while (!que.empty()) {
		auto p = que.front(); que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + vx[i], ny = p.second + vy[i];
			if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
			if (min_cost[nx][ny] != -1) continue;//もう来た
			if (grid[ny][nx] == '#') continue;//進めない
			min_cost[nx][ny] = min_cost[p.first][p.second] + 1;
			que.emplace(nx, ny);
		}
	}
	return min_cost[gx][gy];
}

int main() {
	cin >> h >> w;
	int m = -1;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) {
		cin >> grid[i][j];
		if (grid[i][j] == '.')m++;
	}
	int a = bfs(0, 0, w - 1, h - 1);
	if (a == -1)cout << a << endl;
	else cout << m - bfs(0, 0, w - 1, h - 1) << endl;
}

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

#define MIN 1
#define MAX 20

using namespace std;

int main(void)
{
  int A,B,T;
  cin >> A >> B >> T;
  if(MIN <= A && A <= MAX && MIN <= B && B <= MAX && MIN <= T && T <= MAX)
  	cout << (int)(((int)((int)T+0.5)/A)*B);
  else
    return -1;
  return 0;
}

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

int main()
{ ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     long long a,b,c,d,n;
      cin>>a>>b>>c>>d>>n;
      c=min(c,4*a);
      c=min(c,2*b);
      d=min(d,2*c);
      cout<<(1LL)*(n>>1)*d+(1LL)*(n&1)*c;
  
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int num = 0;
        int sum = 0;
        
        for(int i=0; i<N; i++){
            
            num = scanner.nextInt();
            
            if(num %2 == 0){
                
                if(num %3 == 0|| num %5 == 0){
                }else{
                    sum = 1;
                    break;
                }
                
            }
            
        }
        
        if(sum==0){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
        
    }
}


Measured memory_bytes: 21844