akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin>>n>>q;
    vector<ll> ans(q);
    set<P1> cnt;
    set<P> now;
    rep(i,n){
      ll s,t,x;
      cin>>s>>t>>x;
      cnt.insert(P1(x,P(s-x,t-x)));
    }
    rep(i,q){
      ll d;
      cin>>d;
      now.insert(P(d,i));
    }
    for(auto itr:cnt){
      ll go=itr.fi;
      ll sta=itr.se.fi;
      ll en=itr.se.se;
      auto itr2=now.lower_bound(P(sta,-1));
      while(itr2!=end(now)){
        if(itr2->fi<en){
          ans[itr2->se]=go;
          now.erase(itr2++);
        }else break;
      }
    }
    for(auto itr:now){
      ans[itr.second]=-1;
    }
    rep(i,q) cout<<ans[i]<<endl;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
int main(){
  long double a,b,x;
  cin >>a>>b>>x;
  cout<<setprecision(19)<<floor(b/x)-ceil(a/x)+1<<endl;
  //cout<<ceil(a/x)<<" "<<ceil(a/x)<<endl;
  return 0;
}

  

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

int main(){
    int n,q;
    cin >> n;
    int S[n];
    for(int i=0;i<n;i++) cin >> S[i];
    cin >> q;
    int cur,ans=0;
    for(int i=0;i<q;i++){
        int begin=0,end=n;
        cin >> cur;
        if(cur < S[0] || S[n-1] < cur) continue;
        while(begin < end){
        if(S[(end + begin)/2] == cur){
            ans++;
            break;
        }
        if(S[(end + begin)/2] < cur) begin = (end + begin)/2+1;
        if(S[(end + begin)/2] > cur) end = (end + begin)/2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

//#define print(s)      cerr << s << endl
//#define print(a, b)      cerr << a << " "  << b << endl
#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

unordered_set<string>ss;
class BShiritori {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		ss.clear();
		in >> n;
		string s, s1;
		in >> s;ss.insert(s);
		for (int i = 0; i < n - 1; ++i) {
			in >> s1;
			if(ss.find(s1) != ss.end() || s[s.size() - 1] != s1[0]){out << "No"; return;}
			s = s1;ss.insert(s);
		}
		out <<  "Yes";
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	BShiritori solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << a * b / 2 << endl;

    return 0;
}

Measured memory_bytes: 764
c = [list(map(int, input().split())) for i in range(3)]

for i in range(3):
    a = min(c[i])
    for j in range(3):
        c[i][j] -= a

for j in range(3):
    b = min(c[0][j], c[1][j], c[2][j])
    for i in range(3):
        c[i][j] -= b

for i in range(3):
    for j in range(3):
        if c[i][j] != 0:
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;
static int dp[21][12][200];

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n, k, s;
		cin >> n >> k >> s;
		if(n == 0 && k == 0 && s == 0){ break; }
		memset(dp, 0, sizeof(dp));
		dp[0][0][0] = 1;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j <= k; ++j){
				for(int t = 0; t <= s; ++t){
					dp[i + 1][j][t] += dp[i][j][t];
					dp[i + 1][j + 1][t + i + 1] += dp[i][j][t];
				}
			}
		}
		cout << dp[n][k][s] << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{	int n;cin>>n;
  unordered_map <string ,int>  m;
  for(int i=0;i<n;i++)
  {
      string s;cin>>s;
      ++m[s];
  }
  cout<<"AC x "<<m["AC"]<<'\n';
  cout<<"WA x "<<m["WA"]<<'\n';
  cout<<"TLE x "<<m["TLE"]<<'\n';
  cout<<"RE x "<<m["RE"]<<'\n';
  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

class Main{
	static int[] sosu= {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,
			73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,
			179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,
			283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,
			419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,
			547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,
			661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,
			811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,
			947,953,967,971,977,983,991,997};
	static int[] wari;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		wari=new int[168];
		for(int i=0; i<168; i++) {
			wari[i]=0;
		}
		int n=sc.nextInt();

		for(int i=n; i>=2; i--) {
			fra(i);
		}
		long res=1;

		for(int i=0; i<168; i++) {
			res=res*(wari[i]+1)%1000000007;
		}
		System.out.println(res);
	}

	public static void fra(int a) {
		for(int i=0; i<168; i++) {
			if(a%sosu[i]==0) {
				wari[i]++;
				fra(a/sosu[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 19924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a;
  in2(n, m);
  rep2(i, 1, 191000000){
    if(m % i == 0){
      if(n * i <= m)
        a = max(a, i);
      if(n * (m / i) <= m)
        a = max(a, (m / i));
    }
  }
  out(a);
  memi;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int x; cin >> x;
    int ans;

    if(x < 105) ans = 0;
    else if(x < 135) ans = 1;
    else if(x < 165) ans = 2;
    else if(x < 189) ans = 3;
    else if(x < 195) ans = 4;
    else ans = 5;

    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
amari = n%10
p = ''
if amari ==2 or amari ==4 or amari ==5 or amari ==7 or amari ==9:
    p = 'hon'
elif amari ==1 or amari ==0 or amari ==6 or amari ==8 :
    p = 'pon'
else:
    p = 'bon'
print(p)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    vl s(n-1);
    rep(i,n-1)s[i] = a[i+1] - a[i];
    int dif = s[0];
    ll res = 1;
    rep(i,n-1){
        if(s[i] == 0)continue;
        if(s[i] * dif < 0)res++,dif = 0;
        else dif = s[i];
    }
    out(res);
}


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[N];
int dp[N];

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

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k and i + j < n; j++)
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
    }

    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int H, W;
string S[110];
int ans[110][110];
int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i == 0 && j == 0) {
				if (S[i][j] == '#') ans[i][j]++;
			}
			if (i != 0 && j == 0) {
				ans[i][j] = ans[i - 1][j];
				if (S[i][j] == '#') {
					if (S[i - 1][j] != '#') {
						ans[i][j]++;
					}
				}
			}
			else if (i == 0 && j != 0) {
				ans[i][j] = ans[i][j - 1];
				if (S[i][j] == '#') {
					if (S[i][j - 1] != '#') {
						ans[i][j]++;
					}
				}
			}
			else if(i != 0 && j != 0) {
				if (S[i][j] == '#') {
					int num1, num2;
					if (S[i - 1][j] == '#') num1 = ans[i - 1][j];
					else num1 = ans[i - 1][j] + 1;
					if (S[i][j - 1] == '#') num2 = ans[i][j - 1];
					else num2 = ans[i][j - 1] + 1;
					ans[i][j] = min(num1, num2);
				}
				else {
					ans[i][j] = min(ans[i - 1][j], ans[i][j - 1]);
				}
			}
			//cout << i << " " << j << " " << ans[i][j] << endl;
		}
	}
	cout << ans[H - 1][W - 1] << endl;
}


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

bool in_circle(double x, double y, double xo, double yo, double r) {
  return ((x-xo)*(x-xo)+(y-yo)*(y-yo) < r*r);
}

int main() {
  int n, m;
  double x[100], y[100], r[100];
  double tx, ty, sx, sy, vx, vy, tp, sp, op, a, b, c, d;
  bool bt, bs, safe;
  while (1) {
    cin >> n;
    if (!n) break;
    for (int i=0; i<n; i++) {
      cin >> x[i] >> y[i] >> r[i];
    }
    cin >> m;
    for (int i=0; i<m; i++) {
      cin >> tx >> ty >> sx >> sy;
      safe = false;
      for (int j=0; j<n; j++) {
        bt = in_circle(tx, ty, x[j], y[j], r[j]);
        bs = in_circle(sx, sy, x[j], y[j], r[j]);
        if (bt ^ bs) {
          safe = true;
          break;
        } else if (!bt && !bs) {
          vx = tx - sx;
          vy = ty - sy;
          a = vy;
          b = -vx;
          c = tx*sy- ty*sx;
          d = fabs(a*x[j]+b*y[j]+c)/sqrt(a*a+b*b);
          if (d <= r[j]) {
            op = vx*x[j]+vy*y[j];
            tp = vx*tx + vy*ty;
            sp = vx*sx + vy*sy;
            if ((tp-op)*(sp-op)<0) {
              safe = true;
              break;
            }
          }
        }
      }
      if (safe) {
        cout << "Safe" << endl;
      } else {
        cout << "Danger" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1224
#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<ll, ll>;

ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;

    return gcd(y, x % y);
}

int main()
{
    ll N, K;
    cin >> N >> K;
    // cout << gcd(N, K) << endl;

    ll tmp = N % K;
    cout << min(tmp, abs(tmp - K)) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func main() {
	s := next()
	m := map[byte]bool{}

	for i := 0; i < len(s); i++ {
		m[s[i]] = true
	}

	for c := 'a'; c <= 'z'; c++ {
		if !m[byte(c)] {
			fmt.Println(string(c))
			return
		}
	}

	fmt.Println("None")
}


Measured memory_bytes: 896
#!/usr/bin/python
# coding: UTF-8

from math import *
import os
import sys

#import scipy.optimize
import numpy as np


##################################################################
if __name__ == "__main__":
    Input = [raw_input() for i in range(2)]
    N = int(Input[0])
    A = list(map(int,Input[1].split()))
    A.sort()
    A.reverse()
    Alise = sum([A[i] for i in np.arange(0,N,2)])
    Bob = sum(A)-Alise
    print Alise-Bob
    
        
    

Measured memory_bytes: 10420
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int>L(100010);
  vector<int>R(100010);
  vector<int>m(n);
  for(int i=0;i<n;i++){
    cin>>m.at(i);
  }
  for(int i=0;i<n;i+=2){
    L.at(m.at(i))++;
  }
  for(int i=1;i<n;i+=2){
    R.at(m.at(i))++;
  }
  int Lc1,Lc2,L1,L2;
  Lc1=Lc2=L1=L2=0;
  for(int i=0;i<100010;i++){
    int nowL=L.at(i);
    if(nowL>Lc1){
      Lc2=Lc1;
      Lc1=nowL;
      L2=L1;
      L1=i;
    }
    else if(nowL>Lc2){
      Lc2=nowL;
      L2= i;
    }
  }
    int Rc1,Rc2,R1,R2;
  Rc1=Rc2=R1=R2=0;
  for(int i=0;i<100010;i++){
    int nowR=R.at(i);
    if(nowR>Rc1){
      Rc2=Rc1;
      Rc1=nowR;
      R2=R1;
      R1=i;
    }
    else if(nowR>Rc2){
      Rc2=nowR;
      R2=i;
    }
  }
  int Rsum =n/2;
  int Lsum = n-n/2;   
  if(L1!=R1){
    cout<<Lsum - Lc1 + Rsum -Rc1;
    return 0;
  }
  else{
    cout << min(Lsum - Lc1+Rsum-Rc2,Lsum-Lc2+Rsum-Rc1);
  }

}

Measured memory_bytes: 1408
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n,m = list(map(int, input().split()))

p = m // 2
for i in range(p):
    print(p-i,p+2+i)

q = m // 2 + 1
if m % 2 == 1:
    for i in range(q):
        print(m+q-i,m+q+i+1)
else:
    for i in range(q-1):
        print(m+q-i,m+q+i+1)








Measured memory_bytes: 9648
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 100005
const int inf=2e+9;

int a[N];

int main()
{
    int n,x;
    LL ans=0;
    cin>>n>>x;
    rep(i,0,n){
        scanf("%d",&a[i]);
    }
    if(a[0]>x){
        ans=a[0]-x;
        a[0]=x;
    }
    rep(i,1,n){
        if(a[i]+a[i-1]>x){
            ans+=a[i]+a[i-1]-x;
            a[i]=x-a[i-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define MAX 500002
#define left (2*(num))
#define right ((2 * num) + 1)
int heaptree[MAX],datanum;

void swap(int *a,int *b){
  int temp = *a;
  *a = *b;
  *b = temp;
}


void maxheap(int num){
  int largest;
  //leftに値が入るデータ個数でかつ、上にあるヒープツリーよりも左の方が大きい時、左の値を返す。
  if(left <= datanum && heaptree[left] > heaptree[num]){
    largest = left;
  }else largest = num;
  //leftに値が入るデータ個数でかつ、上にあるヒープツリーよりも右の値の方が大きい時、右の値を返す。
  if(left <= datanum && heaptree[right] > heaptree[largest]){
    largest = right;
  }
  //最大値が
  if(largest != num){
    swap(&heaptree[num],&heaptree[largest]);
    maxheap(largest);
  }
}

void print(int a[],int datanum){
  int i;
  for(i=1;i<=datanum;i++){
    printf(" %d",a[i]);
  }
  printf("\n");
}


int main(){
  int i;
  scanf("%d",&datanum);
  //1から初めてデータ個数分配列に挿入する
  for(i=1;i<=datanum;i++){
    scanf("%d",&heaptree[i]);
  }
  //データの個数/2をしてそこから確かめると、子供がいるノードのみチェックすることができる。
  for(i = datanum/2 ;i>=1;i--)maxheap(i);
  print(heaptree,datanum);
  return 0;
}




Measured memory_bytes: 3684
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  int h,n;
  cin >> h >> n;
  int sum = 0;
  for(int i=1;i<=n;i++){
    int x;
    cin >> x;
    sum+=x;
  }
  if(sum>=h){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }


return 0;
}
///....


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = 1
for i in range(N):
    if (A[i]%(2*3) == 0) or(A[i]%(2*5) == 0) or( A[i]%(2) == 1):
        flag = 1
    else:
        flag = 0
        print('DENIED')
        break
if flag == 1:
    print('APPROVED' )


Measured memory_bytes: 9180
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n; cin >> n;
	VI a(n); rep(i, n)cin >> a[i];

	VI print;
	int q; cin >> q;
	rep(z, q) {
		int com, b, e;
		cin >> com >> b >> e;
		if (com == 0) {
			int min = INT_MAX;
			for (int i = b; i < e; i++)if (min > a[i])min = a[i];
			print.pb(min);
		}
		else {
			int max = INT_MIN;
			for (int i = b; i < e; i++)if (max < a[i])max = a[i];
			print.pb(max);
		}
	}
	for (auto ans : print) {
		cout << ans << endl;
	}
}


Measured memory_bytes: 3156
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
using mint = modint998244353;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, D;
  cin >> N >> D;
  vector<int> X(N), Y(N);
  REP(i, N) cin >> X[i] >> Y[i];
  two_sat ts(N);
  REP(i, N) FOR(j, i+1, N) {
    if(abs(X[i]-X[j]) < D) ts.add_clause(i, false, j, false);
    if(abs(X[i]-Y[j]) < D) ts.add_clause(i, false, j, true);
    if(abs(Y[i]-X[j]) < D) ts.add_clause(i, true, j, false);
    if(abs(Y[i]-Y[j]) < D) ts.add_clause(i, true, j, true);
  }
  if(!ts.satisfiable()) {
    cout << "No" << "\n";
    return 0;
  }
  cout << "Yes" << "\n";
  auto ans = ts.answer();
  REP(i, N) {
    if(ans[i]) cout << X[i] << "\n";
    else cout << Y[i] << "\n";
  }
}

Measured memory_bytes: 3800
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* Binary Indexed Tree(1-index) */

struct BIT{
  typedef int Type;
  int bit_size;
  vector<Type> data;
  
  BIT(int n){
    bit_size = n;
    data.assign(n+2, 0);
  }
  
  //add x to kth value
  void add(int k, Type x){
    k++;
    while(k <= bit_size){
      data[k] += x;
      k += k & (-k);
    }
  }
  
  //sum of [1,k]
  Type query(int k){
    k++;
    Type rec = 0;
    while(k > 0){
      rec += data[k];
      k -= k & (-k);
    }
    return rec;
  }
};



int main(){
  int n;
  ll K;
  int a[SIZE];

  
  scanf("%d%lld", &n, &K);

  K = (ll)n*(n+1)/2 - K + 1;
  
  a[0] = 0;

  for(int i=1;i<=n;i++){
    scanf("%d", a+i);
    a[i] ^= a[i-1];
  }

  int ans = 0;
  ll sum = 0;
  int mask = 0;
  
  for(int i=19;i>=0;i--){
    BIT bit(1<<20);
    int next_ans = ans + (1<<i);
    ll p = 0;

    mask += 1 << i;
    
    for(int j=n;j>=0;j--){
      int t = (a[j] & mask) ^ ans;
      int s = t + (1 << i);
      p += bit.query(s-1) - bit.query(t-1);
      bit.add(a[j], 1);
    }
    
    if(p + sum < K){
      sum += p;
      ans = next_ans;
    }
  }

  cout << ans << endl;
  
  return 0;
}




Measured memory_bytes: 7628
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int n;
ll arr[400];
ll dp[400][400];
ll sum[400][400];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
		sum[i][i] = arr[i];
	}
	for (int len = 2; len <= n; len++) {
		for (int j = 0; j + len <= n; j++) {
			sum[j][j + len - 1] = sum[j + 1][j + len - 1] + arr[j];
			dp[j][j + len - 1] = INFLL;
			for (int k = j; k < j + len - 1; k++) {
				dp[j][j + len - 1] = min(dp[j][j + len - 1],
					dp[j][k] + dp[k + 1][j + len - 1] + sum[j][j + len - 1]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 2688
S = input()
L = len(S)
A = [0 for i in range(L)]
f = 0
c = 0
P = 0
for i in range(L):
  if S[i] == "R":
    if f == 0:
      c += 1
    else:
      A[P] += c // 2
      A[P+1] += (c+1) // 2
      c = 1
      f = 0
  else:
    if f == 1:
      c += 1
    else:
      P = i-1
      A[P] += (c+1) // 2
      A[P+1] += c // 2
      c = 1
      f = 1
A[P] += c // 2
A[P+1] += (c+1) // 2
for a in A:
  print(a)

Measured memory_bytes: 80132
a = list(map(lambda x: int(x), input().split()))
N = a[0]
K = a[1]
sushis = []
for i in range(0, N):
  sushis.append(list(map(lambda x: int(x), input().split())))

sushis.sort(key=lambda x:x[1], reverse=True)

netas = set()
duplicates = []

choices = sushis[:K]

for choice in choices:
  if choice[0] in netas:
    duplicates.append(choice[1])
  else:
    netas.add(choice[0])

p = sum(map(lambda x: x[1], choices)) + len(netas)**2
answer = p

for sushi in sushis[K:]:
  if sushi[0] not in netas and duplicates:
    netas.add(sushi[0])
    duplicate = duplicates.pop()
    p += (sushi[1] - duplicate) + 2*len(netas) - 1
    answer = max(answer, p)

print(answer)


Measured memory_bytes: 30856
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

ll mod_pow(ll n, ll p, ll mod){
    // 繰り返し二乗法で (n^p) % mod を求める
    if(p==0) return 1;
    ll res = mod_pow(n*n%mod, p/2, mod);
    if(p%2==1) res = res * n % mod;
    return res;
}

int main(){
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    ll mod = 1e9+7;

    // 2N-1 までの階乗を求める
    vector<ll> fct(2*N,1);
    for(ll i=1; i<2*N; i++){
        fct[i] = i * fct[i-1] % mod;
    }

    // 2N-1 までの階乗の逆元を求める
    vector<ll> invfct(2*N,1);
    invfct[2*N-1] = mod_pow(fct[2*N-1], mod-2, mod) % mod;
    for(ll i=2*N-2; i>=1; i--){
        invfct[i] = (i+1)*invfct[i+1] % mod;
    }

    // 1/(A+B) ～ 1/(A+B)^2N を求める
    vector<ll> invAB(2*N+1,1);
    invAB[1] = mod_pow(A+B, mod-2, mod);
    for(int i=1; i<=2*N; i++){
        invAB[i] = invAB[i-1]*invAB[1] % mod;
    }
    
    // A^1 ～ A^N と B^1 ～ B^N を求める
    vector<ll> powA(N+1,1), powB(N+1,1);
    powA[1] = A, powB[1] = B;
    for(int i=1; i<=N; i++){
        powA[i] = powA[i-1] * A % mod;
        powB[i] = powB[i-1] * B % mod;
    }

    // シグマの計算を行う。
    ll ans = 0;
    for(int M=N; M<=2*N-1; M++){
        // 二項係数の部分を計算する
        ll tmp = fct[M-1]*invfct[N-1] % mod;
        tmp = tmp * invfct[M-N] % mod;

        // {} で囲まれた部分
        tmp = tmp * (powA[N]*powB[M-N]%mod + powA[M-N]*powB[N]%mod) % mod; // 分子
        tmp = tmp * invAB[M+1] % mod; // 分母

        tmp = tmp * M % mod;

        ans = (ans + tmp)%mod;
    }

    // 全体を 100 倍
    ans = ans * 100 % mod;
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

using namespace std;
int main(){
    cs;
    ll n,a,t;
    cin>>n>>a;
    rep(i,4) {cin>>t;a=min(a,t);}
    t=n/a;
    if(n%a) t++;
    cout<<t+4;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    string s;
    cin>>s;
    s[k-1]=s[k-1]+32;
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
const long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll k;
	cin >> k;
	vector<bool> mp(k, false);
	ll x = 7, ans = 1;
	while (1) {
		if (x % k == 0) {
			cout << ans << endl;
			return 0;
		}
		if (mp[x % k]) {
			cout << -1 << endl;
			return 0;
		}
		mp[x % k] = true;
		x *= 10;
		x %= k;
		x += 7;
		x %= k;
		ans++;
	}
}

Measured memory_bytes: 3772
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

int a, b;

int main() {
    cin >> a >> b;
    if (a < b) {
        REP(i, b) {
            cout << a;
        }
    }
    else {
        REP(i, a) {
            cout << b;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1195& lang=jp		"Encryption System"?????¨??????
????????????1.5h
????????????25????????????????????§???????????????????????????????????\????????\????????????
*/
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main(){
    string a;
    while(cin>>a && a!="#"){	//??????????????????????????????????????????
        queue<string> q;	//????????????25??????????????§?§£??????????????£??????????????§??????????????????????????????????????????????????\???
        q.push(a);
        for(int i=122;i>98;i--){	//z??????c?????§
            q.push("END");	//?§£?????§?????¨???????????????????????????"END"?????\???
            char b=i;
            while(1){
                a=q.front();	//q????????????????????????
                q.pop();	//q??????????????????
                if(a=="END") break;	//END???????¬?????????????????????????
                for(int j=0;j<a.size();j++){
                    if(a[j]==b-1){
                        a[j]=b;	//?§£?????????
                        q.push(a);	//?§£??????????????????q?????\??????
                        a[j]=b-1;	//??????????????????????????§????????????????????¢???
                    }
                    if(a[j]==b) break;	//?§£?????????
                    if(j==a.size()-1) q.push(a);	//?????????????????´???
                }
            }
        }
        q.push("END");
        char b=98;	//b???????????°n????±???????????????§??\????§£???
        int n=0;
        while(1){
            a=q.front();
            q.pop();
            if(a=="END") break;
            for(int j=0;j<a.size();j++){
                if(a[j]==b-1){
                    a[j]=b;
                    q.push(a);
                    n++;
                    a[j]=b-1;
                }
                if(a[j]==b) break;
                if(j==a.size()-1){
                    q.push(a);
                    n++;
                }
            }
        }
        cout<<n<<endl;
        priority_queue<string,vector<string>,greater<string>> pq;	//?????????????????????
        while(!q.empty()){
            string k=q.front();
            pq.push(k);
            q.pop();
        }
        for(int i=0;i<n;i++){
            string k=pq.top();
            if(i<5 || i>=n-5) cout<<k<<endl;	//?????????5???????????????5????????????
            pq.pop();
        }
    }
}

Measured memory_bytes: 4496
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] s = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
            if (s[0] == -1 && s[1] == -1 && s[2] == -1) {
                break;
            }
            if (s[0] == -1 || s[1] == -1) {
                System.out.println("F");
            } else if (s[0] + s[1] >= 80) {
                System.out.println("A");
            } else if (s[0] + s[1] >= 65) {
                System.out.println("B");
            } else if (s[0] + s[1] >= 50) {
                System.out.println("C");
            } else if (s[0] + s[1] >= 30) {
                if (s[2] >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else if (s[0] + s[1] < 30) {
                System.out.println("F");
            }
        }
    }
}

Measured memory_bytes: 26144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner input = new Scanner(System.in)) {
            while (true) {
                int n = input.nextInt();
                if (n == 0) {
                    break;
                }
                int[] scores = new int[n];
                double sum = 0;

                for (int i = 0; i < scores.length; i++) {
                    scores[i] = input.nextInt();
                    sum += scores[i];
                }
                double average = (double) sum / (double) n;
                double a2 = 0.0;
                for (int i = 0; i < scores.length; i++) {
                    a2 += (scores[i] - average) * (scores[i] - average) / n;
                }
                System.out.println(Math.sqrt(a2));
            }
        }
    }
}



Measured memory_bytes: 31264
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
 
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
 
int32_t main(){ fast;
	ll yy; cin>>yy;
	ll x = 100;
	for(int y = 1; y <= 5000; y++){
		ll add = x * 0.01;
		x += add;
		//debug(x);
		if(x >= yy){
			cout<<y<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		StringBuilder sb = new StringBuilder();
		for (int j = 0; j < w; j++) {
			if (j < a) {
				sb.append(1);
			} else {
				sb.append(0);
			}
		}
		for (int i = 0; i < b; i++) {
			System.out.println(sb.toString());
		}

		sb = new StringBuilder();
		for (int j = 0; j < w; j++) {
			if (j < a) {
				sb.append(0);
			} else {
				sb.append(1);
			}
		}
		for (int i = 0; i < h - b; i++) {
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5, mod = 1e9 + 7;

int solve(int i, int j, vector<int>& a, vector<int>& sum, int dp[401][401]) {
	if (i == j)
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];

	int minCost = (1ll << 60);
	int curr_sum = sum[j] - sum[i - 1];

	for (int k = i; k < j; k++) {
		minCost = min(minCost, curr_sum + solve(i, k, a, sum, dp) + solve(k + 1, j, a, sum, dp));
	}
	return dp[i][j] = minCost;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> a(n + 1), sum(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}

	int dp[401][401];
	memset(dp, -1, sizeof dp);
	cout << solve(1, n, a, sum, dp) << endl;

	return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, w;
int inp[105][3];
ll dp[105][100005];

ll solve(int i, int rem) {
    if(rem < 0)
        return (ll) -1e9;
    if(i == n)
        return 0LL;
    ll &rt = dp[i][rem];
    if(rt != -1)
        return rt;
    rt = solve(i + 1, rem);
    rt = max(rt, solve(i + 1, rem - inp[i][0]) + inp[i][1]);
    return rt;
}

int main() {
    IO;
    cin >> n >> w;
    for(int i = 0; i < n; i++)
        cin >> inp[i][0] >> inp[i][1];
    memset(dp, -1, sizeof dp);
    cout << solve(0, w);
    return 0;
}


Measured memory_bytes: 82304
import cmath
def norm(c):
    a = abs(c)
    return a*a
def dot_product(a,b):
    return (a.conjugate()*b).real
def cross_product(a,b):
    return (a.conjugate()*b).imag
def projection(p,b):
    return b*dot_product(p,b)/norm(b)
P = []
try:
    while True:
        x,y = map(float,input().strip().split(","))
        P.append(complex(x,y))
except EOFError:
    pass
N = len(P)
total = 0.0
for i in range(1,N-1):
    a,b,c = P[0],P[i],P[i+1]
    total += cross_product(b-a,c-a)
print("%.6f" % (abs(total)/2.0))



Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    string s;
    vector<int> num(4, 0);
    rep(i, n){
        cin >> s;
        if(s[0]=='A'){
            num[0]++;
        }
        if (s[0] == 'W') {
          num[1]++;
        }
        if (s[0] == 'T') {
          num[2]++;
        }
        if (s[0] == 'R') {
          num[3]++;
        }
    }

    cout << "AC x " << num[0] << endl;
    cout << "WA x " << num[1] << endl;
    cout << "TLE x " << num[2] << endl;
    cout << "RE x " << num[3] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define el cout<<endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    repeat (i, H) cin >> s[i];
    vector<int> dw {1, 0, -1, 0};
    vector<int> dh {0, 1, 0, -1};
    
    repeat (h, H) {
        repeat (w, W) {
            if (s[h][w] == '.') continue;
            bool anysharp = false;
            repeat (k, 4) {
                if (h + dh[k] < 0 or h + dh[k] >= H) continue;
                if (w + dw[k] < 0 or w + dw[k] >= W) continue;
                if (s[h+dh[k]][w+dw[k]] == '#') anysharp = true;
            }
            if (anysharp) continue;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
u=d=z=r=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=(j-i)//2*2;r+=(j-i)%2
    elif j-i==0:z+=1
    else:d+=j-i
print("Yes" if u+2*d>=0 else "No") 

Measured memory_bytes: 11260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 998244353;
const int MAXN = 4010;
int Pow[MAXN], C[MAXN][MAXN];
ll calc(int cnt, int num, int n)
{
	ll ans = 0;
	for(int i = 0; i <= min(cnt, n); ++i)
		(ans += (ll)C[cnt][i] * Pow[i] % MOD * C[n + num - 1][i + num - 1] % MOD) %= MOD;
	return ans;
}
int main()
{
	C[0][0] = Pow[0] = 1;
	for(int i = 1; i < MAXN; ++i) Pow[i] = (Pow[i - 1] << 1) % MOD;
	for(int i = 1; i < MAXN; ++i)
	{
		C[i][0] = 1;
		for(int j = 1; j <= i; ++j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	int k, n; scanf("%d %d", &k, &n);
	for(int i = 2; i <= 2 * k; ++i)
	{
		int cnt = min(k, i - 1) - max(1, i - k) + 1;
		if(i & 1) printf("%lld\n", calc(cnt >> 1, k - cnt, n));
		else printf("%lld\n", (calc(cnt >> 1, k - cnt, n) + calc(cnt >> 1, k - cnt, n - 1)) % MOD);
	}
	return 0;
}


Measured memory_bytes: 61696
s = input()
t = 'abcdefghijklmnopqrstuvwxyz'
if len(s) == len(t):
  for i in range(24,-1,-1):  
    for j in range(25,i,-1):
      if s[j] > s[i]:
        print(s[:i]+s[j])
        exit()
  print(-1)
  exit()
else:
  for i in t:
    if i not in s:
      print(s+i)
      exit()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int count = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != i+1){
            count +=1;
        }
    }
    if(count <= 2){
        puts("YES");
    }else{
        puts("NO");
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

const int MAX=2000010;

vll fac(MAX);
vll finv(MAX);
vll inv(MAX);

void combinit(ll m){
    fac[0]=1;fac[1]=1;
    finv[0]=1;finv[1]=1;
    inv[1]=1;
    rep2(i,2,MAX){
        fac[i]=fac[i-1]*i%m;
        inv[i]=m-inv[m%i]*(m/i)%m;
        finv[i]=finv[i-1]*inv[i]%m;
    }
}

ll combi(ll n,ll k,ll m=inf){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%m)%m;
}

int main(){
    ll k;cin>>k;
    string s;cin>>s;
    ll n=s.size();
    ll ans=(ll)0,tmp=(ll)1;
    vll tf(k+1);tf[0]=(ll)1;
    rep(i,k){
        tf[i+1]=tf[i]*(ll)25;
        tf[i+1]%=inf;
    }
    combinit(inf);
    for(ll i=(ll)0;i<=k;i++){
        ans+=(combi(n+k-i-(ll)1,n-(ll)1)*((tf[k-i]*tmp)%inf))%inf;
        ans%=inf;
        tmp*=(ll)26;tmp%=inf;
    }
    cout<<ans<<endl;
}

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

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

  std::vector<int> in(n);
  for(int i = 0;i<n;++i){
    std::cin >> in[i];
  }

  std::vector<int> dp(n);
  dp[0] = 0;
  dp[1] = std::abs(in[1] - in[0]);
  for(int i = 2;i < n;i++){
    dp[i] = std::min((dp[i - 1] + std::abs(in[i] - in[i - 1])) ,(dp[i - 2]+ std::abs(in[i] - in[i - 2])));
  }

  std::cout << dp[n-1] << std::endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
n = int(input())
d = list(map(int,input().split()))

d.sort()

if d[int(len(d)/2)] == d[int(len(d)/2 - 1)]:
    print(0)
    exit()
    
print(d[int(len(d)/2)] - d[int(len(d)/2 - 1)])

Measured memory_bytes: 24924
import java.util.Scanner;
class Main{
    public static void main(String[]args){
      Scanner stdIn=new Scanner(System.in);
      int a=stdIn.nextInt();
      int b=stdIn.nextInt();
      int c=stdIn.nextInt();
      if(1<=a && a<=500 && 1<=b && b<=500 && 1<=c && c<=1000){
        if(a+b>=c){
          System.out.println("Yes");
        }else
        System.out.println("No");
      }
}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n; char str[305];
int a[305][305],Ans;

int main(){
	scanf("%d",&n);
	F(i,1,n){
		scanf("%s",str+1);
		F(j,1,n) a[i][j]=str[j];
	}
	F(k,1,n){
		int Ok=1;
		F(i,1,n) F(j,1,n){
			int I=(j-k-1+n)%n+1;
			int J=(i+k-1)%n+1;
			if(a[i][j]!=a[I][J]) Ok=0;
		}
		if(Ok) Ans+=n;
	} printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 640
use proconio::*;

fn run() {
    input! {
        n: usize,
    }
    let mut dp = vec![0u16; n + 1];
    for i in 1..=n {
        let mut j = i;
        while let Some(p) = dp.get_mut(j) {
            *p += 1;
            j += i;
        }
    }
    let mut ans = 0u64;
    for (i, dp) in dp.iter().enumerate() {
        let a = *dp as u64;
        let b = i as u64;
        ans += a * b;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 21532
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(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 dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


void solve(int ca){
    int X,N; cin>>X>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    int ans=-1;
    int mini=X+1;
    for (int i = 0; i <= 101; ++i) {
        if(!binary_search(a.begin(),a.end(),i)){
            if(abs(X-i)<mini){
                mini=abs(X-i);
                ans=i;
            }
        }
    }
    cout<<ans<<endl;


}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3628
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

h, w = map(int, input().split())
s = [[j for j in input()] for i in range(h)]
# print(s)
for i in range(h):
    flag = False
    for j in range(w):
        if s[i][j] == "#":
            con1 = True
            con2 = True
            con3 = True
            con4 = True
            if 0 <= i + 1 < h:
                if s[i + 1][j] == ".":
                    con1 = False
            if 0 <= j - 1 < w:
                if s[i][j - 1] == ".":
                    con2 = False
            if 0 <= i - 1 < h:
                if s[i - 1][j] == ".":
                    con3 = False
            if 0 <= j + 1 < w:
                if s[i][j + 1] == ".":
                    con4 = False
            if con1 == con2 == con3 == con4 == False:
                flag = True
                # print(i, j)
                print("No")
                break
    if flag:
        break
else:
    print("Yes")


Measured memory_bytes: 5076