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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n,k;
  cin >> n >> k;
  vi cnt(n);
  rep(i,n){
    int a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  sort(all(cnt));
  int sum = 0;
  rep(i,n){
    if(!cnt[i] == 0) sum++;
  }
  int ans = 0;
  rep(i,n){
    if(cnt[i] == 0) continue;
    if(sum <= k) break;
    sum--;
    ans += cnt[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = float('inf')
dp = [INF for i in range(N)]
dp[0],dp[1] = 0,abs(h[0]-h[1])
for i in range(N):
    ub = K+1 if i+K+1<N else N-i
    for j in range(1,ub):
        c = abs(h[i]-h[i+j])+dp[i]
        dp[i+j] = min(dp[i+j],c)
print(dp[N-1])


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

using namespace std;
using ll = long long;

void solve(){
	int a,b,c;
	cin >> a >> b >> c; 
	cout << min(b/a,c) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [[] for _ in range(N)]
for i in range(N):
  X[i].append(list(map(int, input().split())))

import numpy as np
count = 0
X = np.array(X)
for i in range(N):
  for j in range(N-i-1):
    dist = np.linalg.norm(X[i]-X[N-j-1])
    if dist.is_integer():
      count += 1
print(count)

Measured memory_bytes: 12452
/*! at_abc132.cc
 *  2020-04-28
 *  GCC+17
 *  Type (opt): ad-hoc
 *  Notes (opt): Tricky condition when b==1, we don't need any extensions
 */

#include <stdio.h>

int main(void)
{
    int a,b;
    scanf("%i %i", &a ,&b);
    if (b==1)
        printf("0\n");
    else if (a>b)
        printf("1\n");
     else
        printf("%d\n", (b-a)%(a-1)?(b-a)/(a-1)+2:(b-a)/(a-1)+1);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

constexpr int MAX_N = 100;
long N, dp[MAX_N + 1][21];
int num[MAX_N];

int main(){
    std::cin >> N;
    for(int i = 0; i < N; ++i) {
        std::cin >> num[i];
    }
    dp[0][num[0]] = 1;
    
    for(int i = 0; i < N - 2; ++i) {
        for(int j = 0; j <= 20; ++j) {
            if(j + num[i + 1] <= 20) dp[i + 1][j] += dp[i][j + num[i + 1]];
            if(j - num[i + 1] >= 0) dp[i + 1][j] += dp[i][j - num[i + 1]];
        }
    }
    
    std::cout << dp[N - 2][num[N - 1]] << std::endl;
    
    return 0;
}

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

const int MAX = 100;
int main() {
	int N, X, m[MAX];
	cin >> N >> X;
	for (int i = 0;i < N;i ++) cin >> m[i];
	int minimum = m[0], sum = 0;
	for (int i = 0;i < N;i ++) {
		minimum = min(minimum, m[i]);
		sum += m[i];
	}
	cout << N + (X - sum) / minimum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

要するに、まずお菓子を全部作り、後は一番粉の要らないお菓子を作った
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> cnt(26);
    rep(i, n) {
        char c;
        cin >> c;
        cnt[(ll)(c - 'A')]++;
    }

    ll ans = 0;
    rep(i, 26) {
        if (cnt[i] != 0) ans++;
    }

    if (ans == 4)
        cout << "Four\n";
    else
        cout << "Three\n";
    return 0;
}

Measured memory_bytes: 3588
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())

    min_mod = 10
    elapsed_time = 0
    for x in [A, B, C, D, E]:
        mod = x % 10
        if 0 < mod < min_mod:
            min_mod = mod
        time = x if x % 10 == 0 else (x // 10 + 1) * 10
        elapsed_time += time

    elapsed_time = elapsed_time - (10 - min_mod)
    print(elapsed_time)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int[] price=new int[n];
        int max=-1;
        int place=-1;
        for(int i=0;i<n;i++){
            price[i]=scn.nextInt();
            if(max<price[i]){
                place=i;
                max=price[i];
            }
        }
        int total=0;
        for(int i=0;i<n;i++){
            if(i==place){
                total+=price[i]/2;
            }else{
                total+=price[i];
            }
        }
        System.out.println(total);
    }
}


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

typedef long long ll;

int main() {
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for (int i = 2; i < MAX; i++) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; i++) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; i++) {
        s[i+1] = s[i] + a[i];
    }

    int Q;
    cin >> Q;
    vector<ll>ans;
    for (int q = 0; q < Q; q++) {
        int l, r;
        cin >> l >> r;
        r++;
        
        ans.push_back(s[r]-s[l]);
    }
    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 2676
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;cin>>S;
  int A=(S[0]-'0')*10+S[1]-'0';
  int B=(S[2]-'0')*10+S[3]-'0';
  if(A>0 && A<13 && B>0 && B<13)cout<<"AMBIGUOUS";
  else if(A>0 && A<13)cout<<"MMYY";
  else if(B>0 && B<13)cout<<"YYMM";
  else cout<<"NA";
  cout<<endl;
}
  
  
  
  


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

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

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;
string s;

int main(void)
{
    omajinai;
    cin >> s;
    ll max = 0;
    ll count = 0;
    rep(i, s.size()) {
        if (s[i] == 'T') count++;
        else /* if (s[i] == 'S') */ count--;
        if (max < count) max = count;
    }
    cout << max * 2 << endl;
    return 0;
}


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

int main(){
  int N,s,t,u,ans,c;
  ans=100000;
  cin>>N;
  for(int i=0;i<N+1;i++){
    c=0;
    u=N-i;
    t=i;
  while(u>0){
    c+=u%6;
    u/=6;
  }
    while(t>0){
      c+=t%9;
    t/=9;
    }
   if(ans>c){
     ans=c;
   }
  }
 cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for (ll i = 1; i <= n; i++)
    {
        ans += (n/i)*((n+i)/i)*i/2;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main(void){
    int a,b,c,x;
    
    cin >> a >> b >> c >> x ;
    int result = 0;
    
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                if(500*i+100*j+50*k == x){
                    result++;
                }
            }
        }
    }
    
    cout << result << endl;
    
}


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


int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < M; i++)
	{
		cin >> y[i];
	}

	int XMAX = X;
	int YMIN = Y;
	for (int i = 0; i < N; i++)
	{
		XMAX = max(XMAX, x[i]);
	}
	for (int i = 0; i < M; i++)
	{
		YMIN = min(YMIN, y[i]);
	}

	if (XMAX < YMIN) cout << "No War" << endl;
	else cout << "War" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    int sum=0;
    if (x==1) {
        sum+=300000;
    } else if (x==2) {
        sum+=200000;
    } else if (x==3) {
        sum+=100000;
    }
    if (y==1) {
        sum+=300000;
    } else if (y==2) {
        sum+=200000;
    } else if (y==3) {
        sum+=100000;
    }
    if (x==1&&y==1) {
        sum+=400000;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

reatInt = lambda: int(sys.stdin.readline())
reatIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]


n, k = reatIntN()
ss = sys.stdin.readline().strip()

l = []
i = 0
if ss[0] == '0':
    l.append((1, 0))
else:
    l.append((0, 0))
while i < len(ss):
    c = ss[i]
    while (i < len(ss)) and (c == ss[i]):
        i += 1
    l.append((int(c), i))

i = 1
ret = 0
while i < len(l):
    q = 1 if  l[i][0] == 0 else 0
    b = i - 1
    e = min(i + 2 * k - q, len(l) - 1)
    ret = max(ret, l[e][1] - l[b][1])
    i += 1
print(ret)

Measured memory_bytes: 22840
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
#include <complex>
#include <cassert>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool isParallel(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) < EPS;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

int main(){
	int x[2], y[2];
	while(cin>>x[0]>>y[0]>>x[1]>>y[1]){
		if(x[0] == 0 && y[0] == 0 && x[1] == 0 && y[1] == 0) break;
		vector<L> l;
		l.pb({P(x[0], y[0]), P(x[1], y[1])});
		rep(i, 2){
			rep(j, 2) cin>>x[j]>>y[j];
			l.pb({P(x[0], y[0]), P(x[1], y[1])});
		}
		bool f = true;
		vector<P> p;
		rep(i, 3) rep(j, i){
			if(isParallel(l[i], l[j]) || (!intersectSS(l[i], l[j]))){
				f = false;
				break;
			}
			p.pb(crosspoint(l[i], l[j]));
		}
		if(f == false){
			cout<<"kyo"<<endl;
			continue;
		}
		double s = cross(p[1]-p[0], p[2]-p[0]);
		//rep(i, 3) cout<<" "<<real(p[i])<<" "<<imag(p[i])<<endl;
		s = abs(s);
		s /= 2.0;
		//cout<<" "<<s<<endl;
		string ans;
		if(s + EPS >		1900000.0) ans = "dai-kichi";
		else if(s + EPS >	1000000.0) ans = "chu-kichi";
		else if( s + EPS >	100000.0) ans = "kichi";
		else if( s < EPS) ans = "kyo";
		else ans = "syo-kichi";
		cout<<ans<<endl;
	}
}

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

using namespace std;

const int N=1e5+5;

long long co[N];
long long ans;
int n,q;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		co[x]++;
		ans+=x;
	}
	cin >> q;
	while(q--)
	{
		int x,y;
		cin >> x >> y;
		ans-=x*co[x];
		ans-=y*co[y];
		co[y]+=co[x];
		co[x]=0;
		ans+=y*co[y];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4408
n = int(input())
t = [int(input()) for _ in range(n)]
t.sort()
c = 1
ans = 0
for i in range(1, n):
    if t[i - 1] == t[i]:
        c += 1
    else:
        if c % 2 != 0:
            ans += 1
        c = 1
if c % 2 != 0:
    ans += 1
print(ans)

Measured memory_bytes: 7388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		String start = S.substring(0, 1);
		String end = S.substring(S.length() - 1, S.length());
		int num = S.length() - 2;
		System.out.println(start + Integer.toString(num) + end);
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
   int H,W,i,j;
   cin >> H;
   cin >> W;

   while(H != 0 && W != 0){
       for(i = 0; i < H; i++){
           for(j = 0; j < W; j++){
               if(i == 0 || j == 0 || i == H-1 || j == W-1){
                   cout << "#";
               }
               else{
                   cout << ".";
               }
           }
           cout << endl;
       }
       cin >> H;
       cin >> W;
       cout << endl;
   }

}


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

int main() {
    int a[3][3];
    for(int i = 0; i <= 2; i++) {
        for(int j = 0; j <= 2; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        for(int j = 0; j <= 2; j++) {
            for(int k = 0; k <= 2; k++) {
                if(a[j][k] == x)
                    a[j][k] = -1;
            }
        }
    }
    int f = 0;
    for(int i = 0; i < 3; i++) {
        if(a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1)
            f = 1;
        if(a[1][1] == -1 && a[2][2] == -1 && a[0][0] == -1)
            f = 1;
        if(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1)
            f = 1;
        if(a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1)
            f = 1;
    }
    if(f == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

unsigned GetDigit(unsigned num){
  return to_string(num).length();
}

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> cnt(9,vector<int>(9,0));
  FOR(i,1,N+1){
    int x = i%10;
    int y = i/pow(10,GetDigit(i)-1);
    if(x!=0&&y!=0){
      cnt[y-1][x-1]++;
    }
  }
  // FOR(i,1,10){
  //   if(i<=N){
  //     cnt[i-1][i-1]++;
  //   }
  // }
  // FOR(i,1,10){
  //   FOR(j,1,10){
  //     string s = "";
  //     s=to_string(i)+s+to_string(j);
  //     int x = stoi(s);
  //     if(x<=N){
  //       cnt[i-1][j-1]++;
  //     }
  //   }
  // }
  // REP(i,4){
  //   FOR(j,0,pow(10,i+1)){
  //     string S;
  //     S=to_string(j);
  //     REP(k,i+1-GetDigit(j)){
  //       S='0'+S;
  //     }
  //     FOR(k,1,10){
  //       FOR(l,1,10){
  //         string s = S;
  //         s=to_string(k)+s+to_string(l);
  //         int x = stoi(s);
  //         if(x<=N){
  //           cnt[k-1][l-1]++;
  //         }
  //       }
  //     }
  //   }
  // }

  ll ans = 0;
  REP(i,9){
    FOR(j,i,9){
      if(i!=j){
        ans+=2*cnt[i][j]*cnt[j][i];
      }else{
        ans+=cnt[i][j]*cnt[j][i];
      }
    }
  }
  // REP(i,9){
  //   REP(j,9){
  //     cout << cnt[i][j];
  //   }
  //   cout << endl;
  // }
  cout << ans << endl;
}

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

int main(void) {
  int N;
  cin >> N;
  
  int N_org = N;
  int sum = 0;
  while (N > 0) {
  	sum += (N % 10);
    N /= 10;
    //cout << N << endl;
  }
  
  if ((N_org % sum) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

struct Edge {
    vector<int> to; //{to_where, weight}
};

vector<int> dfs(vector<vector<Edge>> graph, int start = 0) {
    // initialize color array with -1
    vector<int> color(graph.size(), -1);
    stack<int> st;
    st.push(start);
    color[start] = 0;
    while (!st.empty()) {
        int u = st.top(); st.pop();
        for (int i = 0; i < graph[u].size(); i++) {
            //access graph[i] edges
            int v = graph[u][i].to[0];
            int w = graph[u][i].to[1];
            if (color[v] < 0) {
                // it's unvisited
                if (w % 2 == 0) {
                    color[v] = color[u];
                }
                else {
                    color[v] = !color[u];
                }
                st.push(v);
            }
        }
    }
    return color;
}
int main() {
    int N; cin >> N;
    vector<vector<Edge>> graph(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        Edge uv = { {v,w} };
        Edge vu = { {u,w} };
        graph[u].push_back(uv);
        graph[v].push_back(vu);
    }
    vi ans = dfs(graph, 0);
    for (auto& val : ans) {
        cout << val << endl;
    }
}

Measured memory_bytes: 33004
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll h,w; cin >> h >> w;
    ll ma =max(h,w);
    ll n; cin >> n;
    cout << (n+ma -1) / ma << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC104.Task2
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            if (Check(line))
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }
        }

        static bool Check(string s)
        {
            long count = 0;

            for (var i = 0; i < s.Length; i++)
            {
                if (i == 0)
                {
                    if (s[0] != 'A')
                    {
                        return false;
                    }
                }
                else if (i >= 2 && i < s.Length - 1 && s[i] == 'C')
                {
                    count++;
                }
                else
                {
                    if (!Char.IsLower(s[i]))
                    {
                        return false;
                    }
                }
            }

            if (count != 1)
            {
                return false;
            }

            return true;
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;

const int INF = 1e10;
const int ZERO = 0;
signed main() {
	int N,x;
	cin >> N >> x;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int answer = 0;
	for(int i = N - 1;i >= 1;i--) {
		if(vec.at(i) + vec.at(i - 1) > x) {
          	int cnt = vec.at(i) + vec.at(i - 1) - x;
			answer += cnt;
			vec.at(i - 1) = max(vec.at(i - 1) - cnt,ZERO);
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> L(N);
for (int i=0;i<N;i++) {
    cin >> L.at(i);
}

sort(L.begin(),L.end());
int tempi,tempj,val;
int ans = 0;
for (int i=0;i<N-2;i++) {
    tempi = L.at(i);
    for (int j=i+1;j<N-1;j++) {
        val = tempi + L.at(j); 
        for (int k=j+1;k<N;k++){
            if (val > L.at(k)) {
                ans += 1;
            }
            else {
                break;
            }

        }
    }
}
cout << ans << endl;
}


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

int main() {
    int N, p, w, g, y;
    cin >> N;
    for (int i = 0; i < N; i++) {
        char S;
        cin >> S;
        if (S == 'P') {
            p++;
        } else if (S == 'W') {
            w++;
        } else if (S == 'G') {
            g++;
        } else {
            y++;
        }
    }
    if (p == 0 || w == 0 || g == 0 || y == 0) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    F = XLMIIS(N)
    P = XLMIIS(N)
    def b(i,c,num_both):
        if i == 10:
            if num_both == 0:
                return -(10**7)*N
            benefit = 0
            for j, p in enumerate(P):
                benefit += p[c[j]]
            return benefit
        c_both = c[:]
        num_both_2 = num_both
        for j in range(N):
            c_both[j] += F[j][i]
            num_both_2 += F[j][i]

        return max(b(i+1,c,num_both),b(i+1,c_both,num_both_2))
    print(b(0,[0]*N,0))


if __name__ == '__main__':
    main()

Measured memory_bytes: 44124
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+5;
using namespace std;
 
int t,n,m,k,x,y,z;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
    }
    printf("%d\n",(n-1+k-2)/(k-1));
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
c = 1
if n%2 == 1:
    aida = n//2
    flag = 0
    while m > 0:
        if flag == 0:
            print(c, c+aida)
            flag = 1
            m-=1
            aida -= 1
        else:
            print(n-c+1,n-c+1-aida)
            flag = 0
            m-=1
            aida -= 1
            c+=1
else:
    aida = n//2-1
    flag = 0
    while m > 0:
        if flag == 0:
            print(c, c+aida)
            flag = 1
            m-=1
            aida -= 1
        else:
            print(n-c+1,n-c+1-aida)
            flag = 0
            m-=1
            aida -= 1
            c+=1


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

int dp[1001][1001];

int main()
{
	int c = 1;

	while(1)
	{
		for(int i = 0; i <= 1000; i++)
			for(int j = 0; j <= 1000; j++)
				dp[i][j] = 0;

		int w, n;
		cin>>w>>n;
		if(w == 0)break;
		int treasure[1000];
		int price[1000];

		for(int i = 0; i < n; i++)
			scanf("%d,%d", &price[i], &treasure[i]);

		for(int i = 0; i < n; i++){
			for(int j = 0; j <= w; j++){
				if(j < treasure[i])
					dp[i + 1][j] = dp[i][j];
				else
					dp[i + 1][j] = max(dp[i][j], dp[i][j - treasure[i]] + price[i]);
			}
		}
	
		int ansWeight;
		for(ansWeight = w - 1; w >= 0; ansWeight--)
			if(dp[n][w] > dp[n][ansWeight])break;
			
		cout << "Case " << c++ <<":"<<endl;
		cout << dp[n][w] << endl;
		cout << ansWeight + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5164
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}
fn main() {
    input!(n: usize);
    input!(mut l: [usize; n]);
    l.sort();
    let m = l[n - 1];
    let sum = l.iter().fold(0, |acc, &x| x + acc) - m;
    if m < sum {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2188
#include <stdio.h>
#include <stdlib.h>
#define N 2000001
#define A_IN 10000

int A[N],B[N],C[A_IN+1];
void CountingSort(int A[],int B[],int n){
  int i,j;
  for(i=0;i<=A_IN;i++)C[i]=0;
  for(j=1;j<=n;j++)C[A[j]]++;
  for(i=1;i<=A_IN;i++)C[i]=C[i]+C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}

int main(){
  int i,j,n;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  CountingSort(A,B,n);

  for(i=1;i<=n;i++){
    if(i==n)printf("%d",B[i]);
    else printf("%d ",B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 17432
def abc145c_average_length():
    import itertools
    import math
    n = int(input())
    x = []
    y = []
    for _ in range(n):
        a, b = map(int, input().split())
        x.append(a)
        y.append(b)
    result = 0
    cnt = 0
    for p in itertools.permutations(range(n)):
        total = 0
        for i in range(n-1):
            total += math.sqrt(pow(x[p[i]]-x[p[i+1]], 2)+pow(y[p[i]]-y[p[i+1]], 2))
        result += total
        cnt += 1
    print(result/cnt)
abc145c_average_length()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	ll ret=0;
	cin>>N;
	
	for(i=1;i<=N;i++) {
		if(i%3==0) continue;
		if(i%5==0) continue;
		ret+=i;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef pair<int,int> pint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int A,B,K;

int main() {
	cin>>A>>B>>K;
	if((B-A)>=2*K){
		int x[K+1];
		int y[K+1];
		Rep(i,K){
			x[i]=A+i;
			y[i]=B-K+i+1;
		}
		Rep(i,K) cout<<x[i]<<endl;
		Rep(i,K) cout<<y[i]<<endl;
	}
	else{
		Rep(i,B-A+1) cout<<A+i<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    if op == '?':
        break
    elif op == '+':
        print(int(a)+int(b))
    elif op == '-':
        print(int(a)-int(b))
    elif op == '*':
        print(int(a)*int(b))
    elif op == '/':
        print(int(a)//int(b))


Measured memory_bytes: 5592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b; cin >> x >> a >> b;
    if(b<=a) cout << "delicious";
    else if(b<=a+x) cout << "safe";
    else cout << "dangerous";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, i, j, sum=0;
  bool flag=true;
  double limit;
  array<int, 110> A={0};
  cin >> N >> M;

  for(i=0; i<N; i++){
      cin >> A[i];
      sum+=A[i];
  }
  
  limit = 1.0 * (sum / (4.0 * M));
  
  sort(A.begin(), A.end(), std::greater<>());

  for(i=0; i<M; i++){
      if(A[i]<limit){
          flag=false;
          break;
      }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

struct Point{
  int x, y;
};

int main(){
  int H, W, D;
  cin >> H >> W >> D;
  
  vector<Point> p(H * W + 1);
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      int A;
      cin >> A;
      
      p[A] = {i, j};
    }
  }
  
  vector<int> mp(H * W + 1, 0);
  for(int i = D; i <= H * W; i++){
    mp[i] = mp[i - D] + abs(p[i].x - p[i - D].x) + abs(p[i].y - p[i - D].y);
  }
  
  int Q;
  cin >> Q;
  for(int q = Q; q-->0;){
    int L, R;
    cin >> L >> R;
    
    cout << mp[R] - mp[L] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2176
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
d = inpl()
d = set(d)
for i in range(n,10**7):
    flag = True
    t = i
    while i:
        tmp = i%10
        if tmp in d:
            flag = False
        i = i//10
    if flag:
        print(t)
        break


Measured memory_bytes: 41448
#input
N, M = map(int, input().split())
H = list(map(int, input().split()))
dp = [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        dp[B-1] = 0
    elif H[A-1] < H[B-1]:
        dp[A-1] = 0
    elif H[A-1] == H[B-1]:
        dp[A-1] = 0
        dp[B-1] = 0

#output
print(sum(dp))

Measured memory_bytes: 20120
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 410;

//head

int n;
int _[N];
ll __[N];
ll dp[N][N];

ll dfs(int l, int r) {
	if(dp[l][r] != -1) return dp[l][r];
	ll &res = dp[l][r] = LINF;
	if(r-l == 1) return res = 0;
	for(int i = l+1; i < r; i++) {
		chmin(res, dfs(l, i) + dfs(i, r) + __[r]-__[l]);
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n) cin >> _[i];
	rep(i, n) __[i+1] = __[i] + _[i];
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, n) << endl;
}

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

int main() {
  while(true) {
    vector<int> jiros;
    int n;
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; ++i) {
      int num;
      cin >> num;
      jiros.push_back(num);
    }
    int left = 32;
    for(int i = 0; ; ++i) {
      left -= (left - 1) % 5;
      if(left <= 0) {cout << 0 << endl;break;}
      cout << left << endl;
      left -= jiros[i % n];
      if(left <= 0) {cout << 0 << endl;break;}
      cout << left << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<tuple<int, int, int>> data(N);
    int x, y, h, sign;
    rep(0, i, N)
    {
        cin >> x >> y >> h;
        if (h != 0)
        {
            sign = i;
        }
        data.at(i) = make_tuple(x, y, h);
    }
    rep(0, i, 101)
    {
        rep(0, j, 101)
        {
            int H = get<2>(data.at(sign)) + abs(get<0>(data.at(sign)) - i) + abs(get<1>(data.at(sign)) - j);
            int flag = 1;
            for (auto a : data)
            {
                int h2 = max(H - abs(get<0>(a) - i) - abs(get<1>(a) - j), 0);
                if (get<2>(a) != h2)
                {
                    flag = 0;
                }
            }
            if (flag)
            {
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define PI 3.14159265358979323846264338327950288419716939937510
inline ld cosine (ld a, ld b, ld c)
{
    return sqrt(a*a + b*b - 2*a*b*cos(c*PI/180));
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ld a, b, h, m;
	cin >> a >> b >> h >> m;
	cout << fixed << setprecision(15) << cosine(a, b, abs(5.5*m - 30*h));
}



















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

int main()
{
    int n;
    cin>>n;
    int curr=1;
    set<int> s;
    s.insert(n);
    while( true)
    {
        if(n%2==0)
        {
            curr++;
            n=n/2;
          //  cout<<"n is "<<n <<" and curr is "<<curr<<"\n";
            if( s.find(n)== s.end() )
            {
                s.insert(n);
            }
            else {
                cout << curr;
                break;
            }

        } else
        {
            n= 3*n+1;
            curr++;
            //cout<<"n is "<<n <<" and curr is "<<curr<<"\n";
            if( s.find(n)== s.end())
            {
                s.insert(n);
            }
            else {
                cout << curr;
                break;
            }
        }
    }
}

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

using i64 = long long;

const int N = 505;

i64 mx[N][N];

int main() {
#ifdef HOME
	freopen("agc16c.in", "r", stdin);
	freopen("agc16c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 huge;
	int n, m, h, w;

	cin >> n >> m >> h >> w;
	if (n % h == 0 && m % w == 0)
		cout << "No\n";
	else {
		cout << "Yes\n";

		huge = i64(5e8) - i64(5e8) % (h * w - 1);
		for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			mx[i][j] = ((i - 1) % h == 0 && (j - 1) % w == 0) ? huge : -(huge / (h * w - 1) + 1);

		for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			cout << mx[i][j] << " \n"[j == m]; }

	return 0; }


Measured memory_bytes: 4864
#include <iostream>
#include <array>

std::array<std::array<bool, 3>, 3> boolBingo;
std::array<std::array<long, 3>, 3> bingo;

void checkNum(long number) {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (bingo[i][j] == number) {
				boolBingo[i][j] = true;
			}
		}
	}
}

bool isBingo() {
	//check row
	for (int i = 0; i < 3; i++) {
		if (boolBingo[i][0] && boolBingo[i][1] && boolBingo[i][2]) {
			return true;
		}
	}

	//check column
	for (int j = 0; j < 3; j++) {
		if (boolBingo[0][j] && boolBingo[1][j] && boolBingo[2][j]) {
			return true;
		}
	}

	//check diagonals
	if (boolBingo[0][0] && boolBingo[1][1] && boolBingo[2][2]) {
		return true;
	}
	if (boolBingo[2][0] && boolBingo[1][1] && boolBingo[0][2]) {
		return true;
	}

	return false;
}

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> bingo[i][j];
		}
	}
	int N;
	std::cin >> N;
	while (N) {
		long num = 0;
		std::cin >> num;
		checkNum(num);
		N--;
	}
	if (isBingo()) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];

void solve()
{
	map<int, int> cnt;
	int n;
	cin >> n;
	int x;
	cin >> x;
	swap(x, n);
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		cnt[arr[i]]++;
	}
	int diff = mod;
	int ans = mod;
	for(int i = -1000; i <= 1000; i++)
	{
		if(cnt[i]) continue;
		int temp = abs(i - x);
		if(temp < diff)
		{
			diff = temp;
			ans = i;
		}
	}
	cout << ans << endl;
}
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 3776
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N, P = map(int, input().split())
    A = list(map(int, input().split()))
    

    count_even, count_odd = 0, 0
    for a in A:
        if a % 2 == 0:
            count_even += 1
        else:
            count_odd += 1
    
    ans = -1
    # print(N, P, A)
    # print(count_even, count_odd)
    if count_odd == 0:
        # 偶数しかない
        if P == 0:
            # 偶数にしたい => どれでもOK
            ans = 2 ** N
        else:
            # 奇数枚は食べられない
            ans = 0
    else:
        # 奇数が1以上存在するので，ある1つ以外の和Sを考える
        # S is odd: 食べたらeven，食べないとodd => 2 ^ (N-1) パターン
        # S is even: 食べたらodd，食べないとeven
        ans = 2 ** (N - 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65620