akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
#define mp make_pair

const ll INF = (ll)1e15;
const int N = 100100;
vector<pli> g[N];
vector<pli> G[N];
int s, t;
ll dist[N];
ll a[N];
ll ans[N];
int n, m;

void dijkstra(int v) {
	set<pli> setik;
	for (int i = 0; i < n; i++) {
		dist[i] = INF;
		if (i == v)
			dist[i] = 0;
		setik.insert(mp(dist[i], i));
	}
	while(!setik.empty()) {
		v = setik.begin()->second;
		setik.erase(setik.begin());
		for (pli e : g[v]) {
			int u = e.second;
			ll w = dist[v] + e.first;
			if (w >= dist[u]) continue;
			setik.erase(mp(dist[u], u));
			dist[u] = w;
			setik.insert(mp(dist[u], u));
		}
	}
}

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

	scanf("%d%d%d%d", &n, &m, &s, &t);
	s--;t--;
	while(m--) {
		int v, u;
		ll a, b;
		scanf("%d%d%lld%lld", &v, &u, &a, &b);
		v--;u--;
		g[v].push_back(mp(a, u));
		G[v].push_back(mp(b, u));
		g[u].push_back(mp(a, v));
		G[u].push_back(mp(b, v));
	}

	dijkstra(s);
	swap(dist, a);
	for (int i = 0; i < n; i++)
		swap(g[i], G[i]);
	dijkstra(t);

	for (int i = 0; i < n; i++)
		ans[i] = a[i] + dist[i];

	for (int i = n - 2; i >= 0; i--)
		ans[i] = min(ans[i], ans[i + 1]);
	for (int i = 0; i < n; i++)
		printf("%lld\n", INF - ans[i]);

	return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<ll> A;
    priority_queue<ll> A_queue;
    for(int i=0; i<N; ++i)
    {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    sort(A.begin(), A.end());
    ll ans = 0;
    while(A.size() > 0)
    {
        ll max = A.back();
        A.pop_back();
        if(A_queue.empty())
        {
            A_queue.push(max);
            continue;
        }

        ans += A_queue.top();
        A_queue.pop();
        A_queue.push(max);
        A_queue.push(max);
        
    }

    cout << ans << endl;
}

Measured memory_bytes: 7992
#include<bits/stdc++.h>
using namespace std;
int i,j,n,k,m=1000000000,a,c;
string s,t;
char tmp;
int main()
{
  cin>>s;if(s[0]!='A')return cout<<"WA",0;
  for(i=1;i<s.size();i++){
    if(s[i]=='C'){
      if(i==1||i==s.size()-1)return cout<<"WA",0;
      else c++;
    }else{
      if(s[i]<97||s[i]>122)return cout<<"WA",0;
    }
  }
  cout<<(c==1?"AC":"WA");
}

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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

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

const int n = 6;

int p[7], q[7];
vector<ld> points;

int main()
{
    for (int i = 0; i < n; i++) scanf("%d", &p[i]);
    for (int i = 0; i < n; i++) scanf("%d", &q[i]);
    points.pb(0);
    points.pb(1);
    for (int i = 0; i < n; i++) points.pb((ld)q[i] / (p[i] + q[i]));
    ld ans = 1;
    for (auto pa : points)
    {
        ld pb = 1 - pa;
        ld sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += max(p[i] * pa / 100, q[i] * pb / 100);
        }
//         cout << pa << ' ' << sum << endl;
        ans = min(ans, sum);
    }
    cout.precision(20);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(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(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  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...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
bool vi[ohara];

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

  cin >> n;
  rep(i, n) {
    cin >> a >> b;
    rrep(j, a, b + 1) vi[j] = true;
  }
  rrep(i, 1, ohara) {
    if (vi[i]) ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 384
//https://atcoder.jp/contests/abc139/tasks/abc139_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
  ll N; cin>>N;
  --N;
  ll ans=(1+N)* N / 2;
  cout<<ans<<endl;
  return 0;
}

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

int N;
int C[100010] = {0};
int K = 0;
int sum = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int A;
        scanf("%d",&A);
        if(C[A] == 0)
        {
            K++;
        }
        C[A]++;
    }
    for(int i = 1; i < 100000 + 1; i++)
    {
        if(C[i] != 0)
        {
            sum += C[i] - 1;
        }
    }
    printf("%d\n",K - sum % 2);
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {

	int inf = 1 << 13;
	int n;
	int l;
	cin >> n >> l;
	int del;
	int min = l;
	int max = l + n - 1;
	int sum = (min + max) * n / 2;
	if (min <= 0 && 0 <= max) {
		del = 0;
	}
	else {
		if (max < 0) {
			del = max;
		}
		else {
			del = min;
		}
	}
	cout << sum - del << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    n_ansl = [0]*(2*(10**5))
    for i in range(1,2*(10**5)):
    # for i in range(1,20):
        cnt = 0
        one_cnt = bin(i).count("1")
        rem = i
        while rem != 0:
            one_cnt = bin(rem).count("1")
            rem = rem%one_cnt   
            cnt += 1
        n_ansl[i] = cnt
 
    n = int(input())
    x = list(input())
    one_cnt = x.count('1')

    if one_cnt == 0:
        for i in range(n):
            print(1)
        exit()
    
    x = x[::-1]

    curr_sum_p1 = 0
    curr_sum_m1 = 0
    dummy = 1
    for i, xi in enumerate(x):
        if xi == '1':
            curr_sum_p1 += pow(2,i,one_cnt+1)
            curr_sum_p1%=(one_cnt+1)
            if one_cnt > 1:
                curr_sum_m1 += pow(2,i,one_cnt-1)
                curr_sum_m1%=(one_cnt-1)
        dummy *= 2
        dummy %= (one_cnt+1)
        
    ansl = [0]*(n)
    for i, xi in enumerate(x):
        if xi == '1':
            if one_cnt > 1:
                diff = (-1)*pow(2,i,one_cnt-1)
                ans = (curr_sum_m1 + diff)%(one_cnt-1)
                ansl[i] = n_ansl[ans]+1
            else:
                ansl[i] = 0
        else:
            diff = pow(2,i,one_cnt+1)
            ans = (curr_sum_p1 + diff)%(one_cnt+1)
            ansl[i] = (n_ansl[ans]+1)
 
 
    # print(ansl)
    for a in ansl[::-1]:
        print(a)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 90240
#include <algorithm>
#include <string>
#include <queue>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
 
using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)
 
typedef vector<int> vi;
typedef vector<vi> vvi;
 
const int INF = 1001001001;
 
int formula(const string& str, int& cur)
{
//  puts(str.substr(cur).c_str());
    if(isdigit(str[cur])){
        ++cur;
        return str[cur-1] - '0';
    }
    if(str[cur] == '-'){
        ++cur;
        return 2 - formula(str, cur);
    }
 
    ++cur;
    int a = formula(str, cur);
    char op = str[cur];
    ++cur;
    int b = formula(str, cur);
    ++cur;
    if(op == '+')
        return max(a, b);
    else
        return min(a, b);
}
 
int main()
{
    char str[128];
    while(scanf("%s", str), str[0]!='.'){
        int n = strlen(str);
        int cnt = 0;
        rep(p, 3) rep(q, 3) rep(r, 3){
            string tmp = str;
            rep(i, n){
                if(tmp[i] == 'P') tmp[i] = p + '0';
                if(tmp[i] == 'Q') tmp[i] = q + '0';
                if(tmp[i] == 'R') tmp[i] = r + '0';
            }
            int cur = 0;
            cnt += formula(tmp, cur) == 2;
        }
 
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 1024
//package Contest091;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        HashMap<String,Integer> map = new HashMap<>();
            int blue = sc.nextInt();
            for(int i=1;i<=blue;i++)
            {
                String str = sc.next();
                if(map.containsKey(str))
                {
                    int value = map.get(str);
                    map.remove(str);
                    map.put(str,value+1);
                }
                else
                    map.put(str,1);
            }
            int red = sc.nextInt();
            for(int i=1;i<=red;i++)
            {
                String str = sc.next();
                if(map.containsKey(str))
                {
                    int value = map.get(str);
                    map.remove(str);
                    map.put(str,value-1);
                }
            }
            int ans =0;
            for(Map.Entry<String,Integer> x:map.entrySet())
            {
                ans = max(ans,x.getValue());
            }
            out.println(ans);
        out.flush();
    }
    private static int max(int a,int b)
    {
        if(a>b)
            return a;
        else
            return b;
    }
}


Measured memory_bytes: 22996
import sys
a,b,c=map(int,input().split())
if a%2==1 or b%2==1 or c%2==1:
    print(0)
    sys.exit(0)
elif a==b and b==c:
    print(-1)
    sys.exit(0)
ans=0
for i in range(1,10000):
    x=a//2
    y=b//2
    z=c//2
    a=y+z
    b=x+z
    c=x+y
    if a%2==1 or b%2==1 or c%2==1:
        ans=i
        break
print(ans)

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

const int N = (int)2e5 + 50;

int n, m1, m2;
vector<int> G1[N], G2[N];
int lab[N];
int cnt[N], res[N];
bool vis[N];
vector<int> cur_vs;

void dfs(int v, int lb) {
    lab[v] = lb;
    for(int nxt : G1[v]) if(lab[nxt] == -1) dfs(nxt, lb);
}

void dfs2(int v) {
    vis[v] = true;
    cur_vs.push_back(v);
    for(int nxt : G2[v]) {
        if(!vis[nxt]) dfs2(nxt);
    }
}

int main() {
    cin >> n >> m1 >> m2;
    for(int i = 0; i < m1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G1[a].push_back(b);
        G1[b].push_back(a);
    }
    for(int i = 0; i < m2; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G2[a].push_back(b);
        G2[b].push_back(a);
    }
    memset(lab, -1, sizeof(lab));
    int cur_lab = 0;
    for(int i = 0; i < n; i++) {
        if(lab[i] == -1) dfs(i, cur_lab++);
    }
    for(int i = 0; i < n; i++) {
        if(!vis[i]) {
            dfs2(i);
            for(int x : cur_vs) cnt[lab[x]] ++;
            for(int x : cur_vs) res[x] = cnt[lab[x]];
            for(int x : cur_vs) cnt[lab[x]] --;
            cur_vs.clear();
        }
    }
    for(int i = 0; i < n; i++) cout << res[i] << " ";
}

Measured memory_bytes: 18944
#include <iostream>
#include <cctype>
using namespace std;
int main(void){
   
    //変数：与えられた英文「 english 」と置く
    char english;
    //変数：各アルファベットの数「 alphabetSum 」と置く
    int alphabetSum[26] = {};
    
    
    while(cin >> english){
        //条件：アルファベットか確認している。そして与えられた英文「 english 」を小文字に変換している
        if( isalpha(english) ) english = tolower(english);
        //アスキーコードを使用してアルファベットの数を数えている
        alphabetSum[english - 'a']++;
    }
    
    for(int i = 0; i < 26; i++){
        cout << (char)('a'+i) << " : " << alphabetSum[i] << endl;
    }

    
    return 0;
}


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

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main () {
    int n;
    string s;
    cin >> n >> s;
    string t = "ABC";
    s = t + "#" + s;
    auto v = z_function(s);
    int cnt = 0;
    for(auto& i: v) {
        if (i == 3) ++cnt;
    }
    cout << cnt;
}



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

void Main(){
  int N, x;
  cin >> N >> x;
  vector<int> vec(N);
  for(auto& v : vec){
    cin >> v;
  }
  sort(vec.begin(), vec.end());

  int ans = 0;
  for(int i = 0; i < N; ++i){
    if(i == N - 1){
      if(vec.at(i) == x) ++ans;
    }
    else {
      if(vec.at(i) <= x){
        x -= vec.at(i);
        ++ans;
      }
      else break;
    }
  }
  cout << ans << endl;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main() {
	int N, odd = 1;;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (tmp % 2 == 0) {
			odd *= 2;
		} else {
			odd *= 1;
		}
	}
	int ans = pow(3, N);
	cout << ans - odd << endl;
}

Measured memory_bytes: 256
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
c=get_array()
a=sorted(c)
b=a[:k]
print(sum(b))
































Measured memory_bytes: 62532
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var s = o.a(1);
  var t = o.a(1);
  var sl = s.length;
  var tl = t.length;
  var dp = Array(tl+1).fill(0).map(a=>Array(2).fill(0).map(a=>[0,""]));
  var f = 0, g = 1;
  for(var i = 0; i < sl; i++){
    for(var j = 0; j < tl; j++){
      if(s[i] === t[j])dp[j+1][g] = [dp[j][f][0]+1, dp[j][f][1]+s[i]];
      else if(dp[j+1][f][0] > dp[j][g][0])dp[j+1][g] = [dp[j+1][f][0], dp[j+1][f][1]];
      else dp[j+1][g] = [dp[j][g][0], dp[j][g][1]];
    }
    f = g, g = 1 ^ f;
  }
  return dp[tl][f][1];
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long K, l=0;
    cin >> K;
    for (int i = 1; i <= K; i++)
    {
        l *= 10;
        l += 7;
        l %= K;
        if (l == 0)
        {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int D; cin >> D;
	switch(D){
		case 22:
			cout << "Christmas Eve Eve Eve" << endl;
			break;
		case 23:
			cout << "Christmas Eve Eve" << endl;
			break;
		case 24:
			cout << "Christmas Eve" << endl;
			break;
		case 25:
			cout << "Christmas" << endl;
			break;
	} // end switch

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	double a, b, x;
	scanf("%lf %lf %lf" , &a, &b, &x);
	if(0.5 * a * a *b >= x){
		double deg = atan((a * b * b)/(2 * x)) * 180 / M_PI;
		printf("%f", deg);
	}
	else{
		double deg = atan(2*(b-x/(a*a))/a) * 180 / M_PI;
		printf("%f", deg);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int main() {
	ll n;
	cin >> n;
	vector <ll> a(n);

	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	bool ans = false;
	for(int i = 0; i < n - 1; i++) {
		if(a[i] == a[i + 1]) {
			ans = true;
			break;
		}
	}
	if( ans == true) {
		cout << "NO" << endl;
	} else {
		cout << "YES"<< endl;
	}
	return 0;
}

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

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

struct Point {
  int x;
  int y;
  int h;

  Point (int x, int y, int h) : x(x), y(y), h(h) {}
};

size_t distance(Point const& p1, Point const& p2) {
  return std::abs(p1.x - p2.x) + std::abs(p1.y - p2.y);
}

bool judge(Point const& c, std::vector<Point> const& ps) {
  return std::all_of
    (ps.cbegin(), ps.cend(),
     [&](Point const& p) {
      if (p.h == 0) {
        return c.h <= distance(c, p);
      } else {
        return c.h == p.h + distance(c, p);
      }
    });
}

Point scan(std::vector<Point> const& ps) {
  Point const p =
    *std::find_if(ps.begin(), ps.end(),
                  [](Point p){return p.h > 0;});

  for (size_t y=0; y<101; y++) {
    for (size_t x=0; x<101; x++) {
      Point c(x, y, 0);
      c.h = p.h + distance(c, p);
      if (judge(c, ps)) return c;
    }
  }
}

int main() {
  size_t N;

  std::cin >> N;

  std::vector<Point> ps;
  ps.reserve(N);

  for (size_t i=0; i<N; i++) {
    int x;
    int y;
    int h;

    std::cin >> x >> y >> h;

    ps.push_back(Point(x, y, h));
  }

  Point ans = scan(ps);

  std::cout << ans.x << ' '
            << ans.y << ' '
            << ans.h << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int T,X;cin>>T>>X;
    cout << fixed << setprecision(9);
    cout << double(T)/double(X) << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c,d,e;
  scanf("%d %d %d",&a,&b,&c);
  d=a-b;
  e=c-d;
  if(e>0)
    printf("%d",e);
  else
    printf("0");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int main() {
    fast_io;

    int n;
    cin >> n;
    if (n >= 30) cout << "Yes\n";
        else cout << "No\n";
}


Measured memory_bytes: 3648
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
x = [0]*(max(p)+1)
for i in range(1,len(x)):
    x[i] = x[i-1] + i
for i in range(1,len(x)):
    x[i] /= i

s = 0
for i in range(k):
    s += x[p[i]]
ans = s

for i in range(k,n):
    s += x[p[i]] - x[p[i-k]]
    ans = max(s,ans)

print(ans)

Measured memory_bytes: 24676
n = int(input())
a = list(map(int, input().split()))
def solve(n, a):
    b, c, d, e = a[0], a[1], a[2], sum(a[3:])
    bc = b + c
    de = d + e
    bci = 1
    dei = 3
    ans = max(b, c, d, e) - min(b, c, d, e)
    for i in range(2, n - 1):
        while i - bci > 1 and (min(b, c) < min(b + a[bci], c - a[bci])):
            b += a[bci]
            c -= a[bci]
            bci += 1
        while dei < n - 1 and (max(d, e) > max(d + a[dei], e - a[dei])):
            d += a[dei]
            e -= a[dei]
            dei += 1
        ans = min(ans, max(b, c, d, e) - min(b, c, d, e))
        bc += a[i]
        de -= a[i]
        c += a[i]
        d -= a[i]
        if i + 1 >= dei:
            d += a[dei]
            e -= a[dei]
            dei += 1
    return ans

print(min(solve(n, a), solve(n, list(a))))

Measured memory_bytes: 102456
one = [1,3,5,7,8,10,12]
two = [2]
three = [4,6,9,11]
kazu = list(map(int, input().split()))
iti = 0
ni = 0
san = 0
for k in kazu:
  if k in one:
    iti += 1
  elif k in two:
    ni += 1
  elif k in three:
    san += 1
if iti == 2 or ni == 2 or san == 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  string num = a + b + c;
  int N = stoi(num,nullptr,10);
  if(N%4 == 0)
    cout << "YES" << "\n";
  else
    cout << "NO" << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int kenCount = sc.nextInt();
			int shiCount = sc.nextInt();
			int i = 0;
			Shi[] list = new Shi[shiCount];
			// Map<Integer, TreeSet<Integer>> yearMap = new HashMap<>();
			while (i < shiCount) {
				Shi shi = new Shi();
				shi.idx = i;
				shi.ken = sc.nextInt();
				shi.year = sc.nextInt();
				list[i] = shi;
				i++;
			}

			Arrays.sort(list, (o1, o2) -> {
				if (o1.ken == o2.ken) {
					return o1.year - o2.year;
				}
				return o1.ken - o2.ken;
			});

			int[] seq = new int[kenCount + 1];
			String[] ans = new String[shiCount];
			for (int j = 0; j < shiCount; j++) {
				seq[list[j].ken]++;
				list[j].birthNum = seq[list[j].ken];
				ans[list[j].idx] = list[j].getNumberStr();
			}

			for (String a : ans) {
				System.out.println(a);
			}
		}
	}

	private static class Shi {
		private int idx = -1;
		private int ken = 0;
		private int year = 0;
		private int birthNum = -1;

		private String getNumberStr() {
			return zero(ken) + zero(birthNum);
		}

		private String zero(int num) {
			String str = String.valueOf(num);
			switch (str.length()) {
			case 1:
				return "00000" + str;
			case 2:
				return "0000" + str;
			case 3:
				return "000" + str;
			case 4:
				return "00" + str;
			case 5:
				return "0" + str;
			case 6:
				return str;
			}
			return str;
		}
	}
}


Measured memory_bytes: 99448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    for(int i=1; i<=3; i++)
    {
        c=a*b*i;
        if(c%2==1)
        {
            cout<<"Yes"<<endl;
            break;
        }
        else
        {
            cout<<"No"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

INF = 10000000000

dp = [INF for i in range(n)]
dp[0] = 0

def chmin(a, b):
    if a > b:
        a = b
    return a

for i in range(1,n):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 13924
def absolute(N,K):
    return abs(N-K)
    
N,K=map(int,input().split())
N=N%K
valuelist = [N%K]

for i in range (0,3):
    i+=1
    N=absolute(N,K)
    valuelist.append(absolute(N,K))
    
    
print(min(valuelist))


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

int main(){
  int n;
  cin >> n;
  map<string,int> cnt;
  rep(i, n) {
  	string s;
    cin >> s;
    cnt[s]++;
  }
  for(string s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << cnt[s] << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
from collections import deque

n = int(input())
arr = [[] for _ in range(n) ]

for i in range(n-1):
    u,v,w =map(int,input().split())
    arr[u-1].append([v-1,w])
    arr[v-1].append([u-1,w])


queue = deque([0])
ans = [0]*n
checked = [0]*n

while queue:
    x =queue.popleft()
    checked[x] = -1
    dis = ans[x]
    for tup in arr[x]:
        if checked[tup[0]]> -1:
            ans[tup[0]]=(dis+tup[1])%2
            queue.append(tup[0])
print(*ans,sep='\n')


Measured memory_bytes: 47660
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break

    for i in range(h):
        for j in range(w):
            if (j+i)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],i,p=0;
  for(i=0;i<n;i++)
  cin>>a[i];
  for(i=0;i<n;i++)
  {
    if(a[i]%2==0)
    {
      if(a[i]%3!=0 && a[i]%5!=0)
      {
        cout<<"DENIED"<<endl;
        p=1;
        break;
      }
    }
  }
  if(p==0)
  cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S,c = 0;
  cin >> K >> S;
  for(int i = 0; i < K+1;i++){
      for(int j = 0; j < K+1;j++){
        if(S -(i+j) <= K &&  0 <= S -(i+j) ){c += 1;}
      }
  }
  cout << c;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
signed main(){
  double r,pi;
  cin>>r;
  pi = M_PI;
  cout<<fixed<<setprecision(17)<<r*2*pi<<"\n";
  return(0);
}


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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<"\n"
#define prints(a) for(auto i: a) cout<<i<<" "; cout<<"\n"
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e]

int main()
{
	fastio;
	int n, k;
	cin>>n>>k;
	int a[n];
	read(a, n);

	sort(a, a+n);

	int ans = 0;
	for(int i=0; i<k; i++)
		ans += a[i];

	cout<<ans<<"\n";

	exit(0);
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> T(N), sum_T(N+1), max_V(N);
    rep(i, N) {
        cin >> T[i];
        sum_T[i+1] = sum_T[i] + T[i];
    }
    rep(i, N) {
        cin >> max_V[i];
        max_V[i] *= 2;
    }
    max_V.push_back(0);
    max_V.insert(max_V.begin(), 0);
    
    int M = sum_T.back();

    vector<int> v(2*M+1, INF); // 0.5 sec interval
    v[0] = v[2*M] = 0;
    while (true) {
        for (int j=1; j<=N; j++) {
            // if (max_V[j] >= max_V[j-1]) {
                int i = j-1;
                int l = 2*sum_T[i], r = 2*sum_T[i+1];
#ifdef DEBUG
                cerr << "A" << endl;
                DUMP2(l, r);
#endif
                if (v[l] != INF) {
                    // for (int t=r-1; t>=l; t--) {
                    for (int t=l+1; t<=r; t++) {
                        v[t] = min(v[t], v[t-1] + 1);
                        v[t] = min(v[t], max_V[j]);
                    }
                }
            }
            // }
           //  if (max_V[j] >= max_V[j+1]) {
            for (int j=N; j>=1; j--) {
                int i = j-1;
                int l = 2*sum_T[i], r = 2*sum_T[i+1];
#ifdef DEBUG
                cerr << "B" << endl;
                DUMP2(l, r);
#endif
                if (v[r] != INF) {
                    // for (int t=l+1; t<=r; t++) {
                    for (int t=r-1; t>=l; t--) {
                        v[t] = min(v[t], v[t+1] + 1);
                        v[t] = min(v[t], max_V[j]);
                    }
                }
            // }
        }
#ifdef DEBUG
        cerr << "---------------" << endl;
        rep(i, 2*M+1) cerr << v[i] << " ";
        cerr << endl;
#endif
        assert(v[0] == 0);
        assert(v[2*M] == 0);

        bool end = true;
        for (int i=0; i<M; i++) {
            end &= (v[i] != INF);
        }
        if (end) break;
    }


    double ans = 0.0;
    rep(i, 2*M) {
        ans += v[i] / 4.0;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <char,int> mp1,mp2;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int n;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>n;
    string s[n];
    
    for(int i=0;i<n;i++)cin>>s[i];
        
    for(int i=0;i<s[0].size();i++) mp1[s[0][i]]++;
    
    for(int i=1;i<n;i++){
        for(int j=0;j<s[i].size();j++){
            mp2[s[i][j]]++;
        }
        for(auto p:mp1){
            if(mp2[p.first]<p.second)mp1[p.first]=mp2[p.first];
        }
        mp2.clear();
    }
    
    for(auto p:mp1){
        for(int i=0;i<p.second;i++)cout<<p.first;
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
def factorial(n):
    ret = 1
    for i in range(n):
        ret *= (i + 1)
    return ret

def calc_order(A, N):
    l = [i + 1 for i in range(N)]
    order = 1
    for i in range(N):
        a = A[i]
        len_l = len(l)
        index = l.index(a)
        # print(a, index, factorial(len_l - 1), order)
        order += index * factorial(len_l - 1)
        del l[index]
    return order

def main():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    ord_p = calc_order(P, N)
    ord_q = calc_order(Q, N)
    ans = abs(ord_p - ord_q)
    # print(ord_p, ord_q)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[100001];
int main(void)
{
	int l,r,res=0,i;
	scanf("%s",str);
	l=0; r=strlen(str)-1;
	while(l<r){
		if(str[l]==str[r]) l++,r--;
		else if(str[l]=='x') res++,l++;
		else if(str[r]=='x') res++,r--;
		else{
			puts("-1");
			return 0;
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	q := readInt()
	s := []byte(readString())
	a := make([]int, n)
	for i := 1; i < n; i++ {
		a[i] = a[i-1]
		if s[i] == 'C' && s[i-1] == 'A' {
			a[i]++
		}
	}

	for i := 0; i < q; i++ {
		l := readInt() - 1
		r := readInt() - 1
		println(a[r] - a[l])
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 4864
#include <stdio.h>

int main(void){
	int player[50];  /* プレイヤーが持っている小石の数 */
	int bowl;  /* 椀に入っている小石の数 */
	int n, p, i;

	while (scanf("%d %d\n", &n, &p) == 2 && n >= 3 && n <= 50 && p >= 2 && p <= 50){
		/* 初期化 */
		for (i = 0; i < n; i++){
			player[i] = 0;
		}
		bowl = p;

		/* ゲーム */
		for (i = 0; ; i++, i %= n){
			if (bowl > 0){
				bowl--;  /* 椀から小石を1つ取る */
				player[i]++;
				if (player[i] == p) break;  /* すべての小石を手にしたので勝利 */
			}else{
				bowl = player[i];  /* 手許の小石をすべて椀に入れる */
				player[i] = 0;
			}
		}

		printf("%d\n", i);
	}

    return 0;
}

Measured memory_bytes: 604
using System;

namespace _0006
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputs;
            inputs = Console.ReadLine();
            for(int i = inputs.Length - 1; i >= 0; i--)
            {
                Console.Write(inputs[i]);
            }
            Console.WriteLine();
        }
    }
}



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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

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

template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}

template <typename T> void print(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void print(const T &value, const Args&... args){std::cout << value << " ";print(args...);}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  string s;
  while(cin >> s){
    for(auto &c : s){
      if(c == '?') c = 'D';
    }
    
    print(s);
    
  }

  return 0;
}


Measured memory_bytes: 3712
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
        
        int x, k, d;
        cin >> x >> k >> d;
        x = abs(x);
        int r = x/d;
        if(r >= k){
        	x -= k * d;
        	cout << x ;
        }
        else{
        	x -= r*d;
        	k -= r;
        	if(k%2 == 0){
        		cout << x;
        	}
        	else{
        		cout << abs(x - d);
        	}
        }
        return 0;
}

Measured memory_bytes: 3656
a=str(input())
s=len(a)
b=str(input())
t=len(b)
if s>t:
    print('GREATER')
elif s<t:
    print('LESS')
else:
    for i in range(s):
        if a[i]>b[i]:
            print('GREATER')
            break
        elif a[i]<b[i]:
            print('LESS')
            break
    else:
        print('EQUAL')

Measured memory_bytes: 38384
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	
	cin >> A >> B;

	cout << (A+B) % 24 << endl;

	
	return 0;
}


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

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

class Main {
 public static void main(String[] args) {
  int sevenCounter = 0;
  int fiveCounter = 0;

  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

  String line;
  try {
   while ((line = br.readLine()) != null) {

    StringTokenizer token = new StringTokenizer(line);

    while (token.hasMoreElements()) {
     if (Integer.parseInt(token.nextElement().toString()) == 7)
      sevenCounter++;
     else
      fiveCounter++;

    }




   }

  } catch (Exception ex) {


  }









  // Scanner sc = new Scanner(System.in);


  //     for (int i = 0; i< 3; i++) {
  //       while (sc.hasNext()) 
  //       {
  //         if (sc.nextInt() == 7)
  //         sevenCounter++;
  //        else 
  //         fiveCounter++; 
  //       }
  //     }





  if (sevenCounter == 1 && fiveCounter == 2) {
   System.out.println("YES");
  } else {
   System.out.println("NO");
  }
 }
}

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


#define dhai_machli ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


bool f[100001];
int c[100002];

int n, l, r;

using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif

   dhai_machli;



   int x, n;

   cin >> x >> n;

   int a[n];

   vector<int> used(110);

   int ans = 110;

   loop(i, n)
   {
      cin >> a[i];

      used[a[i]] = 1;
   }

   for (int i = 110; i >= 0; i--)
   {
      if (used[i]) continue;

      if (abs(ans - x) >= abs(i - x))
      {
         ans = i;
      }

   }

   cout << ans << endl;


   return 0;
}


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

long long merge(int A[],int left,int mid,int right);
long long mergeSort(int A[],int left,int right);

const int Sentinel = 2000000000;

int main(){
	int n,*A; cin>>n;
	A = new int[n];
	for(int i=0;i<n;i++) cin>>A[i];

	long long count = mergeSort(A,0,n);
	cout<<count<<endl;

	//for(int i=0;i<n;i++){
	//	if(i) cout<<" ";
	//	cout<<A[i];
	//}
	//cout<<endl;

	delete [] A;
	cin.sync(); cin.get();
}

long long merge(int A[],int left,int mid,int right){
	int n1 = mid-left , n2 = right-mid, *L, *R; long long count = 0;
	L = new int[n1+1]; R = new int[n2+1];
	for(int i=0;i<n1;i++) L[i] = A[left+i];
	for(int i=0;i<n2;i++) R[i] = A[mid+i];
	L[n1] = R[n2] = Sentinel;
	int i = 0, j = 0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]) A[k] = L[i++];
		else{
			A[k] = R[j++];
			count += n1-i;
		}
	}
	delete [] L; delete [] R;
	return count;
}

long long mergeSort(int A[],int left,int right){
	long long count1 = 0, count2 = 0, count3 = 0;
	if(left+1<right){
		int mid = (left+right)/2;
		count1 = mergeSort(A,left,mid);
		count2 = mergeSort(A,mid,right);
		count3 = merge(A,left,mid,right);
		return count1+count2+count3;
	}else return 0;
}

Measured memory_bytes: 4344
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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

		ArrayList<String> snList = new ArrayList<String>();

		for(int i = 0; i < N; i++) {
			snList.add(sc.next());
		}

		Collections.sort(snList,Comparator.naturalOrder());

		for(int i = 0; i < N; i++) {
			System.out.print(snList.get(i));
		}
	}

}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = ll(1e10)+1;

void Main() {
  int A[3][3];
  bool B[3][3];
  rep(i, 3) rep(j, 3) cin >> A[i][j];
  rep(i, 3) rep(j, 3) B[i][j] = false;
  int n;
  cin >> n;
  rep(_, n) {
    int b;
    cin >> b;
    rep(i, 3) rep(j, 3) if(b==A[i][j]) B[i][j] = true;
  }
  rep(i, 3) if ( B[i][0] && B[i][1] && B[i][2] ) {
    cout << "Yes" << endl;
    return;
  }
  rep(i, 3) if ( B[0][i] && B[1][i] && B[2][i] ) {
    cout << "Yes" << endl;
    return;
  }
  if ( B[0][0] && B[1][1] && B[2][2] ) {
    cout << "Yes" << endl;
    return;
  }
  if ( B[0][2] && B[1][1] && B[2][0] ) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

int main(){
  int h, w;
  std::cin >> h >> w;
  char pic[h][w];
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      scanf(" %c", &pic[i][j]);
  for(int i = 0; i < h + 2; i++){
    for(int j = 0; j < w + 2; j++){
      if(i == 0 || j == 0 || j == w + 1 || i == h + 1)
        std::cout << "#" ;
      else{
          std::cout << pic[i - 1][j - 1];
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

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

signed main() {
    int n; cin >> n;
    vector<int> v(n + 1, 0);
    for(int i = 0; i < n; i++) cin >> v[i];

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(i == v[i] - 1) {
            swap(v[i], v[i + 1]);
            ans++;
        }
    }

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


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

void fnInput(string& rsMaxNum)
{
  cin >> rsMaxNum;
}

int fnDgtDP(string sMaxNum)
{
  // dp[i][j][k] :=  i: 上位 i 桁目まで決定
  //                 j: small(数字を自由に選べる)か
  //                 k: {3,5,7} を選んだかのflag
  //                 の条件を満たす数値の数
  int dp[11][2][8] = {};
  dp[0][0][0] = 1;

  int nLen = sMaxNum.size();

  for (int i = 0; i < nLen; ++i)
  {
    for (int j = 0; j < 2; ++j)
    {
      for (int k = 0; k < 8; ++k)
      {
        if (!dp[i][j][k]) continue;

        if (j == 1)                    // small ([0, 9] から数字を選べる)か
        {
          if (!k) dp[i + 1][1][0] += dp[i][1][0];            // nothing

          dp[i + 1][1][k | 1] += dp[i][1][k];                // +3
          dp[i + 1][1][k | 2] += dp[i][1][k];                // +5
          dp[i + 1][1][k | 4] += dp[i][1][k];                // +7
        }
        else                           // not small ([0, d] から数字を選べる)か
        {
          int nDgt = sMaxNum[i] - '0';

          if (!k)        dp[i + 1][1][0]     += dp[i][0][0]; // nothing

          if (nDgt == 3) dp[i + 1][0][k | 1] += dp[i][0][k]; // +3
          if (3 < nDgt)  dp[i + 1][1][k | 1] += dp[i][0][k]; // +3
          if (nDgt == 5) dp[i + 1][0][k | 2] += dp[i][0][k]; // +5
          if (5 < nDgt)  dp[i + 1][1][k | 2] += dp[i][0][k]; // +5
          if (nDgt == 7) dp[i + 1][0][k | 4] += dp[i][0][k]; // +7
          if (7 < nDgt)  dp[i + 1][1][k | 4] += dp[i][0][k]; // +7
        }
      }
    }
  }
  return dp[nLen][0][7] + dp[nLen][1][7];
}

int main()
{
  string sMaxNum;

  fnInput(sMaxNum);
  cout << fnDgtDP(sMaxNum) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int i,j,k;//制御
char str[15];
int maru=0,batu=0;

scanf("%s",str);

for(i=0;i<15;i++){
    if(str[i]=='o'){
        maru++;
    }
    else if(str[i]=='x'){
        batu++;
    }
}
if(batu<=7){
    printf("YES");
}
else if(maru>=8){
    printf("YES");
}
else
{
    printf("NO");
}


return 0;

}


Measured memory_bytes: 128