akhauriyash/Code-Regression huggingface dataset:
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T ipow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b;
    return n % 2 == 0 ? mypow(b * b, n / 2) : mypow(b, n - 1) * b;
}

template <typename T, typename U>
T mpow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    return n % 2 == 0 ? mypow(b * b % MOD, n / 2) : mypow(b, n - 1) * b % MOD;
}

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

    ld ans = 0;
    for (int i = 0; i < N; ++i) {
        ld x;
        string u;
        cin >> x >> u;
        ans += x * (u == "JPY" ? 1 : 380000);
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (fabs(a - b) < fabs(a - c))	printf("A\n");
	else printf("B\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>

#define AB	(0)
#define AC	(1)
#define BC	(2)

#define resA		(0)
#define resB		(1)
#define resC		(2)

#define false (1==0)
#define true	(1==1)

char search(int* S,int N,int A,int B,int C,int* route){
	if(A<0||B<0||C<0){
		return false;
	}
	if(N==0){
		return true;
	}
	switch(*S){
	case AB:
		if(search(S+1,N-1,A+1,B-1,C,route+1)){
			*route=resA;
			return true;
		}
		if(search(S+1,N-1,A-1,B+1,C,route+1)){
			*route=resB;
			return true;
		}
		break;
	case AC:
		if(search(S+1,N-1,A+1,B,C-1,route+1)){
			*route=resA;
			return true;
		}
		if(search(S+1,N-1,A-1,B,C+1,route+1)){
			*route=resC;
			return true;
		}
		break;
	case BC:
		if(search(S+1,N-1,A,B-1,C+1,route+1)){
			*route=resC;
			return true;
		}
		if(search(S+1,N-1,A,B+1,C-1,route+1)){
			*route=resB;
			return true;
		}
		break;
	}
	return false;
}

int main(){
	int N,A,B,C;
	int ret;
	ret=scanf("%d %d %d %d",&N,&A,&B,&C);
	int S[N];
	int route[N];
	for(int i=0;i<N;i++){
		char buf[3];
		scanf("%s",buf);
		if(!strcmp(buf,"AB")){
			S[i]=AB;
		}else if(!strcmp(buf,"AC")){
			S[i]=AC;
		}else if(!strcmp(buf,"BC")){
			S[i]=BC;
		}
	}
	ret=search(S,N,A,B,C,route);
	if(ret){
		printf("Yes\n");
		for(int i=0;i<N;i++){
			switch(route[i]){
			case resA:
				printf("A\n");
				break;
			case resB:
				printf("B\n");
				break;
			case resC:
				printf("C\n");
				break;
			}
		}
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 10252
#include <stdio.h>
 
using namespace std;
 
int main(){
    int m,f,r;
    char grade;
    while(true){
        scanf("%d %d %d",&m,&f,&r);
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1){
            grade = 'F';
        }else if(m+f >= 80){
            grade = 'A';
        }else if(m+f >= 65){
            grade = 'B';
        }else if(m+f >= 50){
            grade = 'C';
        }else if(m+f >= 30){
            grade = (r >= 50)? 'C':'D';
        }else{
            grade = 'F';
        }
        printf("%c\n",grade);
    }
}


Measured memory_bytes: 2768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl


int main() {
	int N;
	cin >> N;
	string S;
	set<string>ST;
	rep(i, N) {
		cin >> S;
		ST.insert(S);
	}
	cout << ST.size() << endl;
}

Measured memory_bytes: 19228
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    _, m = [int(e) for e in input().split()]

    N = []
    for l in sys.stdin:
        N.append([int(e) for e in l.strip().split()])
    N.sort(key=lambda x: x[0])
    total = 0
    for l in N:
        if m <= l[1]:
            total += l[0] * m
            m = 0
        else:
            m -= l[1]
            total += l[0] * l[1]
        if m == 0:
            break
    print(total)

main()


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class BHarshadNumber {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;

    int s = 0;
    int d = 1;
    for (int i = 0; i < 9; i++){
        s += (n / d) % 10;
        d *= 10;
    }

    cout << (n % s == 0 ? "Yes" : "No") << endl;
}
};

int main() {
	BHarshadNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;
const int inf = 1000000000;

int abs(int a){
    if(a < 0) return -a;
    return a;
}

int main(){
    int n, w;
    cin >> n >> w;
    vector<int> ws(n, 0);
    vector<long long> vs(n, 0);
    for(int i = 0; i< n; i++){
        cin >> ws[i] >> vs[i];
    }
    long long dp[w+1];
    for(int i = 0; i < w+1; i++){
        dp[i] = 0;
    }

    for(int i = 0; i < n; i++){
        for(int j = w; j >= 0; j--){
            if(j + ws[i] <= w){
                dp[j + ws[i]] = max(dp[j+ws[i]], dp[j]+vs[i]);
            }
        }
    }

    long long result = dp[0];
    for(int i = 0; i<=w; i++){
        if(result < dp[i]) result = dp[i];
    }

/*
    for(int i = 0; i < n+1; i++){
        for(int j = 0; j < w+1; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 50
 
int main(){
    double r;
    int n;
    while(cin >> r >> n, r){
	int H[MAX] = {0},xl,xr,h;
	for(int i = 0 ; i < n ; i++){
	    cin >> xl >> xr >> h;
	    xl += 20; xr += 20;
	    for(int j = xl ; j < xr ; j++){
		H[j] = max(H[j],h);
	    }
	}
	double res = (1<<29);
	for(int i = 20-r ; i < 20+r ; i++){
	    double rr = i-20+(i<20);
	    res = min(res,r+H[i]-sqrt(r*r-rr*rr));
	}
	printf("%.8f\n",res);
    }
    return 0;
}

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        long [] a = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            sum += a[i];
        }
        long mod = ((long) n * (n + 1)) / 2;
        if (sum % mod != 0) {
            out.println("NO");
            out.close();
            return;
        }
        sum /= mod;
        long [] sol = new long[n];
        for (int i = 0; i < n - 1; i++) {
            long dif = a[i + 1] - a[i];
            if (sum - dif < 0 || (sum - dif) % n != 0) {
                sol[n - 1 - i] = -1;
                continue;
            }
            sol[n - 1 - i] = (sum - dif) / n;
        }
        for (int i = 0; i < n; i++) {
            if (sol[i] == -1) {
                out.println("NO");
                out.close();
                return;
            }
        }
        out.println("YES");
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 46308
unittest
{
	assert( [ "3", "4" ].parse.expand.solve == 5 );
	assert( [ "19", "100" ].parse.expand.solve == 261 );
	assert( [ "10", "0" ].parse.expand.solve == 100 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto a = input.front.strip.to!( long );
	return tuple( n, a );
}

auto solve( long n, long a )
{
	return n * n - a;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i =  0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int ans = 1;
  for (int i = 0; i < n - 1; i++) {
    if (vec.at(i) < vec.at(i + 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"5
6 7 9 10 31"# => r#"APPROVED"#,

r#"3
28 27 24"# => r#"DENIED"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize,
        a: [usize; n],
    }

    let even = a.iter().filter(|&x| x % 2 == 0).cloned().collect::<Vec<usize>>();
    let b = even.iter().filter(|&&x| x % 3 == 0 || x % 5 == 0);
    if b.count() == even.len() {
        "APPROVED"
    } else {
        "DENIED"
    }.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int N,K;

bool ok(int mid,vector<ll> &a) {
  if(mid==N) return true;
  if(mid==-1) return false;
  vector<vector<bool>> dp(N+1,vector<bool>(K,false));
  dp[0][0] = true;
  rep(i,N) {
    rep(j,K) {
      if(i==mid) {
	dp[i+1][j] = dp[i][j];
	continue;
      }
      if(dp[i][j]) {
	dp[i+1][j] = true;
	if(j+a[i] < K) dp[i+1][j+a[i]] = true;
      }
    }
  }
  for(int i =max(0,(int)(K - a[mid])); i < K; i++) {
    if(dp[N][i]) return true;
  }
  return false;
}

int b_search(vector<ll> &a) {
  int l = -1,r = N,mid;
  while(r-l>1) {
    mid = (l+r)/2;
    // cout<<mid<<endl;
    if(ok(mid,a)) r = mid;
    else l = mid;
  }
  return r;
}

int main(){
  cin>>N>>K;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];
  sort(a.begin(),a.end());
  int ans = b_search(a);
  cout<<ans<<endl;
}


Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll long long
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}

ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
    int n,k;
    int cnt;
    int num = 1;
    cin >> n >> k;
    while (num <= n){
      num *= k;
      cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

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

	int n,ans;
	ans = 0;
	cin >> n;
	vector<int> v(n), c(n);

	for (int i = 0; i < n;i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n;i++) {
		cin >> c[i];
	}

	for (int i = 0; i < n; i++) {
		if (v[i] > c[i]) {
			ans += (v[i] - c[i]);
		}
	}
	cout << ans << endl;


	
}	






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

int search_best_color(vector<int> &colors, int a) {
    int l = 0;
    int r = colors.size() - 1;
    while ((r-l) > 1) {
        int c = (l + r) / 2;
        if (colors[c] < a) {
            r = c;
        } else {
            l = c;
        }
    }
    if (colors[l] < a) {
        return l;
    } else if (colors[r] < a) {
        return r;
    } else {
        return -1; /* abort */
    }
}

int main() {
    int N;
    cin >> N;
    int color_n = 0;
    vector<int> colors;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (color_n == 0) {
            colors.push_back(a);
            color_n++;
        } else if (colors[color_n-1] >= a) {
            colors.push_back(a);
            color_n++;
        } else {
            int j = search_best_color(colors, a);
            colors[j] = a;
        }
    }
    cout << color_n << "\n";
    return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

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

		while(scan.hasNext())
		{
			int N = scan.nextInt();
			int K = scan.nextInt();
			for(int i=0;i<K;i++)
			{
				int x = scan.nextInt()-1;
				int y = scan.nextInt()-1;

				if(x>N/2)
					x = N-1-x;
				if(y>N/2)
					y = N-1-y;
				int ans = Math.min(x,y);
				System.out.println(ans%3+1);
			}
		}
	}
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  map<ll,ll>mp;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n){
    cin>>a[i];
    mp[a[i]]++;
  }
  for(auto z:mp)res+=(z.se)*(z.se-1)/2;
  rep(i,0,n){
    ll k=mp[a[i]];
    cout<<res-(k*(k-1))/2+max(0LL,(k-1)*(k-2)/2)<<endl;
  }
  return 0;
}

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

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

  if (a == b) {
    cout << c << endl;
  }else if(b == c) {
    cout << a << endl;
  } else {
    cout << b << endl;
  }
}

Measured memory_bytes: 3580
W,H,N = map(int,input().split())
minx,maxx,miny,maxy = 0,W,0,H
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        minx = max(x,minx)
    if a == 2:
        maxx = min(x,maxx)
    if a == 3:
        miny = max(y,miny)
    if a == 4:
        maxy = min(y,maxy)
print(max(0, maxx - minx) * max(0, maxy - miny))

Measured memory_bytes: 3064
N, A, B = [int(_) for _ in input().split()]
ans = 0
if N == 1 or A == B:
    ans += A == B
elif N == 2:
    ans = 2 * (A < B)
elif B > A:
    ans = (N - 2) * (B - A) + 1
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;
class Main {
	public void pi() {
		Scanner sc = new Scanner(System.in);
		int i = 1;
		int x = sc.nextInt();
		while(x != 0) {
			System.out.println("Case" + " " + i + ":" + " " + x);
			x = sc.nextInt();
			i++;
		}
	}
	public static void main(String[] args) {
		new Main().pi();
	}
}

Measured memory_bytes: 32984
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

void solve() {
  // main coding
  int INF=1e9;
  int n; cin>>n;
  vector<int> H(n);
  rep(i,n) cin>>H[i];
  vector<int> dp(n,INF);
  dp[0]=0; dp[1]=abs(H[1]-H[0]);
  for(int i=2;i<n;++i) {
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[202020];
ll ans;
ll i, j, k;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        j += A[i];
    }
    k = 0;
    ans = 1e18;
    fornum(i,1,N){
        k += A[i - 1];
        j -= A[i-1];
        ans = min(ans, abs(k - j));
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1792
import sys

input = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def main():
    N = int(input())

    divs = make_divisors(N)
    ans = float("inf")
    for d in divs:
        ans = min(ans, max(len(str(N // d)), len(str(d))))

    print(ans)

    

if __name__ == '__main__':
    main()



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

int main(){
	int n,m,x; cin>>n>>m>>x;
	vector<int> v(n+1);
	rep(i,m){
		int a; cin>>a;
		v[a]++;
	}
	int t0=0;
	for(int i=x; i>=0; i--) t0+=v[i];
	int tn=0;
	for(int i=x; i<n+1; i++) tn+=v[i];
	cout<<min(t0,tn)<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  vector<int> vec(5);
  for(int i = 0; i < 5; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < 5; i++){
    if(vec.at(i) == 0){
      cout << i+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3512
N = int(input())
A = list(map(int,input().split()))
over = 0
M = [0 for _ in range(8)]
for a in A:
    if 1 <= a <= 399:
        M[0] = 1
    elif 400 <= a <= 799:
        M[1] = 1
    elif 800 <= a <= 1199:
        M[2] = 1
    elif 1200 <= a <= 1599:
        M[3] = 1
    elif 1600 <= a <= 1999:
        M[4] = 1
    elif 2000 <= a <= 2399:
        M[5] = 1
    elif 2400 <= a <= 2799:
        M[6] = 1
    elif 2800 <= a <= 3199:
        M[7] = 1
    elif 3200 <= a:
        over += 1
count = sum(M)
if count == 0:
    print(str(1)+' '+str(over))
else:
    print(str(count)+' '+str(count+over))

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

int main() {
  int H,N;
  cin >> H >> N;
  
  int A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    H -= A;
  }
   if (H <= 0) cout << "Yes" << endl;
   if (H > 0) cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;
int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
      cin>>v[i];
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
          s+=v[i]*v[j];
    }
    cout<<s;
}


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

int main()
{
    int n;
    cin >> n;
    int p[n];
    int ans = 0;
    for(int i=0;i<n;i++){cin >> p[i];}
    for(int j=1;j<n-1;j++){
        if(p[j-1] < p[j] && p[j] < p[j+1]){
            ans++;
        }
        else if(p[j+1] < p[j] && p[j] < p[j-1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  ll A,B,K;
  cin>>A>>B>>K;
  ll KK=K;
  K=max(K-A,0ll);
  A=max(A-KK,0ll);
  B=max(B-K,0ll);
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n+1, vector<int> (m+1, 0));
    string ans = "";
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=m;j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else
            {
                if(dp[i-1][j] > dp[i][j-1])
                {
                    dp[i][j] = dp[i-1][j];
                }
                else
                {
                    dp[i][j] = dp[i][j-1];
                }
            }
        }
    }
    int i = n, j = m;
    while(i > 0 and j > 0)
    {
        if(s[i-1] == t[j-1])
        {
            ans.push_back(s[i-1]);
            i -= 1;
            j -= 1;
        }
        else
        {
            if(dp[i][j-1] > dp[i-1][j])
            {
                j -= 1;
            }
            else
            {
                i -= 1;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 38500
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    rep(i,0,N-1){
        if(A[i] == A[i+1]){
            print("NO");
            return 0;
        }
    }
    print("YES");
    

}

Measured memory_bytes: 1792
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int P = scanner.nextInt();
        scanner.close();

        int piece = A * 3 + P;

        int count = piece / 2;

        System.out.println(count);

//        System.out.println(System.currentTimeMillis() - startTime);
    }


}


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

int main(){
  int N, score=0, max=0;  
  string str;
  cin >> N;
  cin >> str;

  for(int i=0; i<N; i++){
    if(str[i] == 'I'){
      score++;
      if(score > max) max = score;      
    }
    else score--;
  }

  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 888
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;
int power(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return ret;
}

int n,k,fac[100111],cnt,f[100111],ans;
int main()
{
	get2(n,k);
	for(int i=1;i*i<=n;i++)
		if(n%i==0)
		{
			fac[++cnt]=i;
			if(n/i!=i)fac[++cnt]=n/i;
		}
	sort(fac+1,fac+cnt+1);
	for(int i=1;i<=cnt;i++)
	{
		f[i]=power(k,fac[i]+1>>1);
		for(int j=1;j<i;j++)if(fac[i]%fac[j]==0)f[i]=(f[i]-f[j]+mod)%mod;
		if(fac[i]%2==1)ans=(ans+1ll*fac[i]*f[i])%mod;
		else ans=(ans+1ll*fac[i]/2*f[i])%mod;
	}
	printendl(ans);
	return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define N 1000005
using namespace std;

void solve(){
	int n,W;
	cin >> n >> W;
	int weight[n],cost[n];
	for(int i = 0; i < n; i++){
		cin >> weight[i] >> cost[i];
	}
	int sum = 0;
	for(int i = 0; i < n; i++){
		sum += cost[i];
	}
	int dp[n + 1][sum + 1];
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= sum; j++)
			dp[i][j] = (1e15);
	}
	dp[0][0] = 0;
	dp[0][cost[0]] = weight[0];
	for(int item = 1; item < n; item++){
		for(int cur_value = 0; cur_value <= sum; cur_value++){
			if(cur_value - cost[item] >= 0 && weight[item] + dp[item - 1][cur_value - cost[item]] <= W)
				dp[item][cur_value] = weight[item] + dp[item - 1][cur_value - cost[item]];
			if(dp[item - 1][cur_value] <= W)
				dp[item][cur_value] = min(dp[item][cur_value], dp[item - 1][cur_value]);
		}
		if(dp[item][cost[item]] == MAX)
			dp[item][cost[item]] = weight[item];
	}
	for(int i = sum; i >= 0; i--){
		if(dp[n - 1][i] != (1e15)){
			cout << i ;
			return ;
		}
	}
}
int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;

int n,m,a[40];

int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int k,tem;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            cin>>tem;
            a[tem]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++)
        if(a[i]==n)ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<set>
using namespace std;
const int MAXN=500000+10;
int n,k,A[MAXN],P[MAXN],Indegree[MAXN],to[MAXN<<1],nex[MAXN<<1],beg[MAXN],Ans[MAXN],cnt,e;
priority_queue<int> q;
set<int> tmp1,tmp2;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
inline void insert(int x,int y)
{
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
}
inline void toposort()
{
	while(!q.empty())
	{
		int x=q.top();
		q.pop();
		Ans[++cnt]=x;
		for(register int i=beg[x];i;i=nex[i])
		{
			Indegree[to[i]]--;
			if(!Indegree[to[i]])q.push(to[i]);
		}
	}
}
int main()
{
	read(n);read(k);
	for(register int i=1;i<=n;++i)
	{
		read(P[i]);
		A[P[i]]=i;
	}
	for(register int i=1;i<k-1;i++)tmp1.insert(P[i]);
	for(register int i=1;i<=n;i++)
	{
		if(i+k-1<=n)tmp1.insert(P[i+k-1]);
		tmp1.erase(P[i-1]);
		tmp2.insert(P[i]);
		if(i>k)tmp2.erase(P[i-k]);
		set<int>::iterator cur=tmp1.upper_bound(P[i]);
		if(cur!=tmp1.end())insert(A[*cur],i),Indegree[i]++;
		cur=tmp2.upper_bound(P[i]);
		if(cur!=tmp2.end())insert(A[*cur],i),Indegree[i]++;
	}
	for(register int i=1;i<=n;++i)
		if(!Indegree[i])q.push(i);
	toposort();
	for(register int i=1;i<=n;++i)A[Ans[i]]=n-i+1;
	for(register int i=1;i<=n;++i)printf("%d\n",A[i]);
	return 0;
}

Measured memory_bytes: 44544
abc = gets.split.map(&:to_i)

max = abc.max
ans = 0
abc =
  abc.map do |x|
    if x < max
      ans += (max - x) / 2
      x += (max - x) / 2 * 2
    end
    x
  end

if abc.count(max) == 1
  ans += 1
elsif abc.count(max) == 2
  ans += 2
end

puts ans


Measured memory_bytes: 3836
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int par,l,r;
};

struct Node T[MAX];
int n,dep[MAX],h[MAX];

int Depth(int u){
  int d=0;
  while(1){
    u = T[u].par;
    if(u == NIL)break;
    d++;
  }
  return d;
}

int Sibling(int u){
  if(T[u].par == NIL)return NIL;
  if(T[T[u].par].l != u && T[T[u].par].l != NIL)return T[T[u].par].l;
  if(T[T[u].par].r != u && T[T[u].par].r != NIL)return T[T[u].par].r;
    return NIL; 
}


int main(){
  int i,id/*node*/,l,r,p,c,deg;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].par = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
        if(l != NIL)T[l].par = id;
    if(r != NIL)T[r].par = id;
  }
  for(i=0;i<n;i++){
    dep[i] = Depth(i);/*depth*/
    h[i] = 0;/*height*/
  }
  for(i=0;i<n;i++){/*height*/
    if(T[i].l == NIL && T[i].r == NIL){
      h[i] = 0;
      p = T[i].par;
      c = 1;
      while(1){
        if(p == NIL)break;
        if(h[p] < c)h[p] = c;
        c++;
        p = T[p].par;
      }
    }
  }
  for(i=0;i<n;i++){/*print*/
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].par);
    printf("sibling = %d, ",Sibling(i));
    deg = 0;
    if(T[i].l != NIL)deg++;
    if(T[i].r != NIL)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",dep[i]);
    printf("height = %d, ",h[i]);

    if(T[i].par == NIL){
      printf("root\n");
    }
    else if(T[i].l == NIL && T[i].r == NIL){
      printf("leaf\n");
    }
    else {
     printf("internal node\n");
    }
  }

  return 0;
}




Measured memory_bytes: 2052
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    vector<int> a(1100);
    iota(a.begin(), a.end(), 1);
    for (int i = 1; i < 1100; i++) {
        a[i] = a[i] + a[i - 1];
    }

    cout << a[B - A - 1] - B << endl;

    return 0;
}


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

int N,M;
int main(){
  cin>>N>>M;
  vector<int> p(M+1,0);
  for(int i=0;i<N;i++){
    int K; cin>>K;
    for(int j=0;j<K;j++){
      int a; cin>>a; p[a]++;
    }
  }
  int ans=0;
  for(int i=1;i<=M;i++){
    if(p[i]==N) ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;
int oya[100000];
int findoya(int p){
     
    if(oya[p]<0){
        return p;
    }else{
        int t=oya[p];
       
        return  oya[p]=findoya(t);
    }
}
     vector<pair<int,int>> p[2];
     signed main(){
   int n,m,q;
   cin>>n>>m>>q;
   ;fill(oya,oya+n,-1);
   
        int a,b,c;
        for(int i=0;i<q;i++){
                cin>>a>>b>>c;
                p[c].push_back(make_pair(a,b));
        }
        for(int i=0;i<p[0].size();i++){
                a=findoya(p[0][i].first);
                b=findoya(p[0][i].second);
                // cerr<<'u';
                if(a==b)continue;
                if(oya[a]<oya[b])swap(a,b);
                oya[b]+=oya[a];
                oya[a]=b;
           

        }
     int l=1;
        for(int i=0;i<p[1].size();i++){
             l=0;
                if(findoya(p[1][i].first)==findoya(p[1][i].second)){
                        cout<<"No";
                        return 0;
                }

        }
        c=0;for(int i=0;i<n;i++)if(oya[i]<0)c++;//cerr<<c<<endl;
       
       
        if(n-l<=m&&m<=n-c+c*(c-1)/2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

         
}

        


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int cntDigits(long long n)
{
    int digits = 0;
    while (n > 0) {
        n /= 10;
        ++digits;
    }
    return digits;
}

int main()
{
    ios::sync_with_stdio(false);
    long long n;
    cin >> n;

    int ans = cntDigits(n);

    for (long long a = 1LL; a * a <= n; ++a) {
        if (n % a != 0) continue;
        const long long b = n / a;
        const int cur = max(cntDigits(a), cntDigits(b));

        if (ans > cur) ans = cur;
    }

    cout << ans << '\n';
}

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

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; }
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N,M;

// *********************************************************



int main(){

    cin>>N>>M;

    map<int, int> mp;

    for(int i=0; i<M; i++){
        int s,c;
        cin >> s >>c;
        auto itr = mp.find(s);
        if(itr != mp.end()){
            if(c != itr->second){
                cout << -1 << endl;
                return 0;

            } 
        }else{
            mp[s]=c;
        }
    }

    auto itr = mp.find(1);
    if(itr != mp.end()){
        if(itr->second == 0 && N != 1){
            cout << -1 << endl;
            return 0;
        }
        cout << mp[1];
    }else if(N==1){
        mp[1] = 0;
        cout <<mp[1];
    }else{
        mp[1] = 1;
        cout << mp[1];
    }

    for(int i=2; i<=N; i++){
        itr = mp.find(i);
        if(itr == mp.end()){
            mp[i] = 0;
        }
        cout << mp[i];

    }
    
    cout << endl;
   

    return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
h=list(map(int,input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=0
for j in range(n):
    for i in g[j]:
        if h[j]<=h[i]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 29648
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

const double EPS = 1e-8;
typedef pair<long double, long double> P;
vector<P> vp1;
vector<P> vp2;

long double width(long double x, const vector<P>& v){
    long double top = -1e8, bottom = 1e8;
    REP(i, v.size()){
        P p1 = v[i], p2 = v[(i + 1) % v.size()];
        if(abs(p1.first - p2.first) < EPS){
            if(abs(p1.first - x) < EPS){
                top = max(top, p1.second);
                top = max(top, p2.second);
                bottom = min(bottom, p1.second);
                bottom = min(bottom, p2.second);
            }
            continue;
        }
        if(p1.first > p2.first) swap(p1, p2);
        if(p1.first - EPS < x && x < p2.first + EPS){
            long double ratio = (x - p1.first) / (p2.first - p1.first);
            long double y = p1.second + ratio * (p2.second - p1.second);
            top = max(top, y);
            bottom = min(bottom, y);
        }
    }
    return max(0.0L, top - bottom);
}
long double f(long double x){
    long double w = width(x, vp1) * width(x, vp2);
    return w;
}

long double simpson(long double l, long double r, int N){
    long double h = (r - l) / (2 * N); 
    long double S = f(l) + f(r);
    for(int i = 1; i < 2 * N; i += 2){
        S += 4.0 * f(l + h * i);
    }
    for(int i = 2; i < 2 * N; i += 2){
        S += 2.0 * f(l + h * i);
    }
    return S * h / 3.0;
}


int main(){
    int M, N;
    while(cin >> M >> N && M){
        vp1.resize(M);
        vp2.resize(N);
        REP(i, M) cin >> vp1[i].first >> vp1[i].second;
        REP(i, N) cin >> vp2[i].first >> vp2[i].second;
        long double left1 = vp1[0].first, right1 = vp1[0].first;
        long double left2 = vp2[0].first, right2 = vp2[0].first;
        REP(i, M) left1 = min(left1, vp1[i].first);
        REP(i, N) left2 = min(left2, vp2[i].first);
        REP(i, M) right1 = max(right1, vp1[i].first);
        REP(i, N) right2 = max(right2, vp2[i].first);
        vector<long double> vx;
        long double left = max(left1, left2), right = min(right1, right2);
        vx.push_back(left); vx.push_back(right);
        REP(i, M) if(left < vp1[i].first && vp1[i].first < right) vx.push_back(vp1[i].first);
        REP(i, N) if(left < vp2[i].first && vp2[i].first < right) vx.push_back(vp2[i].first);
        long double S = 0;
        sort(vx.begin(), vx.end());
        REP(i, vx.size() - 1){
            S += simpson(vx[i], vx[i + 1], 100);
        }
        printf("%.16Lf\n", S);
    }
    return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
    double a,b,h,m,p,r,i,n,l;
    cin>>a>>b>>h>>m;
    i=m/5;n=(2*acos(0.0));
    if(h>=i)
    p=((abs(h-i)+(m/60))*(n/180)*30);
    else
     p=((abs(h-i)-(m/60))*(n/180)*30);
    r=cos(p);
    l=sqrt(a*a+b*b-2*a*b*r);
    cout.precision(20);
    cout<<fixed<<l;

    return 0;

}


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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)


using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T>& val) {
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T>& val) {
  return val.first + val.second;
}


template <typename T>
T min(T a, T b, T c) {
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c) {
  return max(max(a, b), c);
}


template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
*/

class mytask {
public:

  mytask() { }


  int solve() {

    ll n;
    cin >> n;
    bool good = true;
    for (ll i = 0; i < n; i++) {
      ll a;
      cin >> a;
      if ((a%2 == 0) && (a%3 != 0 && a%5 != 0)) {
        good = false;
      }
    }
    if (good) {
      cout << "APPROVED";
    } else {
      cout << "DENIED";
    }

    return 0;
  }




};


int main() {

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

  auto task = mytask();
  task.solve();


  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;
  
  int ans = -1;
  int tax1, tax2;
  for(int i=1;i<=1009;i++){
    tax1 = (int)floor(i*0.08);
    tax2 = (int)floor(i*0.1);
    if(tax1 == A && tax2 == B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int X;
    cin >> X;
    int dp[X + 1000]{};
    dp[0] = 1;
    int a[6] = {100, 101, 102, 103, 104, 105};
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < X; j++) {
            if (dp[j] == 1) {
                dp[j + a[i]] = 1;
            }
        }
    }
    cout << dp[X] << "\n";
    return 0;
}

Measured memory_bytes: 640