akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
vector<vector<int>>adj(N);


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}

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


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        vii a(n);
        for(int i=0;i<n;i++){
            cin>>get<0>(a[i])>>get<1>(a[i]);
        }
        int cnt=0;
        int f=0;
        for(int i=0;i<n;i++){
            if(a[i].first==a[i].second){
                cnt++;
            }
            else{
                if(cnt>=3){
                    f=1;
                    break;
                }
                cnt=0;
            }
        }
        if(f || cnt>=3)
            Yes();
        else
        {
            No();
        }
        
    }
    return 0;
}

Measured memory_bytes: 7812
#include <iostream>
#include <map>
using namespace std;
int main() {
    int N, A, cnt = 0;
    map<int, int> m;
    map<int, int>::iterator itr;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        itr = m.find(A);
        if (itr == m.end()) m[A] = 1;
        else m[A]++;
    }
    for (itr = m.begin(); itr != m.end(); ++itr) {
        if (itr->second % 2) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int a; cin >> a;
    string s; cin >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


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

#define N_MAX 36

using namespace std;

struct Trump{
	char suit;
	int value;
};

void BubbleSort(Trump* C, const int N);
void SelectionSort(Trump* C, const int N);
bool isStable(const Trump* input, const Trump* output, const int* valList, const int N);
void swap(Trump& x, Trump& y);

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

	int N, valueCountList[9] = {0};
	Trump cardsOrg[N_MAX], cardsSorted1[N_MAX], cardsSorted2[N_MAX];
	string input;

	cin >> N;
	for(int i = 0; i < N; ++i) {
		cin >> input;
		cardsOrg[i].suit = input[0];
		cardsOrg[i].value = input[1] - '0';
		valueCountList[cardsOrg[i].value - 1]++;
	}

	memcpy(cardsSorted1, cardsOrg, sizeof(Trump) * N);
	memcpy(cardsSorted2, cardsOrg, sizeof(Trump) * N);

	BubbleSort(cardsSorted1, N);
	SelectionSort(cardsSorted2, N);

	for(int i = 0; i < N; ++i) {
		cout << cardsSorted1[i].suit << cardsSorted1[i].value << (N - 1 == i ? "\n" : " ");
	}
	cout << (isStable(cardsOrg, cardsSorted1, valueCountList, N) ? "Stable" : "Not stable") << endl;
	for(int i = 0; i < N; ++i) {
		cout << cardsSorted2[i].suit << cardsSorted2[i].value << (N - 1 == i ? "\n" : " ");
	}
	cout << (isStable(cardsOrg, cardsSorted2, valueCountList, N) ? "Stable" : "Not stable") << endl;

	return 0;
}

void BubbleSort(Trump* C, const int N) {
	for(int i = 0; i < N; ++i){
		for(int j = N - 1; j > i; --j){
			if(C[j].value < C[j - 1].value){
				swap(C[j], C[j - 1]);
			}
		}
	}
}

void SelectionSort(Trump* C, const int N) {
	for(int i = 0; i < N; ++i) {
		int minj = i;
		for(int j = i; j < N; ++j) {
			if(C[j].value < C[minj].value) {
				minj = j;
			}
		}
		swap(C[i], C[minj]);
	}
}

bool isStable(const Trump* input, const Trump* output, const int* valList, const int N){
	int count;
	char suit[2][4];

	for(int i = 0; i < 9; ++i){
		if(2 <= valList[i]){
			memset(suit, 0, sizeof(suit));
			count = 0;
			for(int j = 0; j < N; ++j) {
				if(input[j].value == i + 1){
					suit[0][count++] = input[j].suit;
					if(valList[i] == count){
						break;
					}
				}
			}

			count = 0;
			for(int j = 0; j < N; ++j) {
				if(output[j].value == i + 1) {
					suit[1][count++] = output[j].suit;
					if(valList[i] == count) {
						break;
					}
				}
			}

			if(0 != strncmp(suit[0], suit[1], valList[i])) {
				return false;
			}
		}
	}
	return true;
}

void swap(Trump& x, Trump& y){
	Trump tmp = x;
	x.suit = y.suit;
	x.value = y.value;
	y.suit = tmp.suit;
	y.value = tmp.value;
}


Measured memory_bytes: 3232
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[101010];
int main()
{
	int n;
	cin>>n;
	int i;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
				cout<<"DENIED"<<endl; 
				return 0;
		}
		
	}
	cout<<"APPROVED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  intmax_t n;
  scanf("%jd", &n);
  std::vector<intmax_t> a(5);
  for (auto& ai: a) scanf("%jd", &ai);

  intmax_t res = 0;
  for (auto ai: a) {
    res = std::max(res, (n+ai-1)/ai+4);
  }
  printf("%jd\n", res);
}


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

using namespace std;

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

	string s, t;
	cin >> s >> t;
	if(s==t.substr(0, s.size()))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;

vector<ll> G[100010];

int main(void) {
    ll n, k;
    cin >> n >> k;

    for (int i = 0; i < n - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool t[100010] = {}, x = false;
    queue<int> que;
    que.push(0);
    t[0] = true;
    ll ans = k, inf = 1e9 + 7;

    while (!que.empty()) {
        int q = que.front(), idx = 0;
        for (int i = 0; i < G[q].size(); i++) {
            if (!t[G[q][i]]) {
                que.push(G[q][i]);
                t[G[q][i]] = true;
                if (x) ans *= (k - idx - 2);
                else ans *= (k - idx - 1);
                ans %= inf;
                idx++;
            }
        }
        x = true;
        que.pop();
    }

    cout << ans << endl;

}
/*
g++ -std=c++14 _main.cpp
 */


Measured memory_bytes: 7156
#include <stdio.h>

int main(void)
{
	int n, x, i, j, k, count;
	
	while (1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0) {
			break;
		}
		
		count = 0;
		for (i = 1; i <= n - 2; i++) {
			for (j = i + 1; j <= n - 1; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}
		
		printf("%d\n", count);
	}
	
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  long long size = s.size();
  long long num = stoll(s);
  long long sum = 0;
  
  vector<int> numnum(size);
  for(long long i = size-1; i >= 0; i--){
    numnum.at(i) = num%10;
    num /= 10;
  }
   
  for(long long i=0; i < ( 1 << (size-1) ); i++){
    long long tmp = 0;
    long long tmp_sum = 0;
    bitset<10> plus(i);
    for(long long j = 0; j < (size); j++){
      if(plus.test(j)){
        tmp_sum += tmp*10 + numnum.at(j);
        tmp = 0;
      }else{
        tmp = tmp*10 + numnum.at(j);
      }
    }
    sum += (tmp_sum + tmp);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n-1) cin >> a.at(i+1);
    vi res(n,0);
    for(int64_t i=1; i<n; i++){
        res.at(a.at(i)-1)++;
    }
    for(int64_t i=0; i<n; i++){
        cout << res.at(i) << endl;
    }
}

Measured memory_bytes: 6284
#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>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; 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)

int main() {
	lint N;
	cin >> N;
	lint ans = 0;
	for (lint i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
a=I()
print(n*n-a)


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

int main() {
  int n; cin >> n;
  int a[200010];
  for ( int i = 0; i < n; i++ ) cin >> a[i];
  list<int>b;
  if ( n % 2 == 0 ) {
  b.push_back(a[0]);
  for ( int i = 1; i < n; i++ ) {
    if ( i % 2 == 1 ) b.push_front(a[i]);
    else b.push_back(a[i]);

  }
  }else {
    b.push_back(a[0]);
    for ( int i = 1; i < n; i++ ) {
      if ( i % 2 == 1 ) b.push_back(a[i]);
      else b.push_front(a[i]);
    }
  }
  list<int>::iterator it;
  for ( it = b.begin(); it != b.end(); it++) {
    cout << *it << " ";
  }
  cout << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  
  while(1) {
    if(n <= 1000) {
      ans = (1000 - n);
      cout << ans << endl;
      break;
    }
    else n -= 1000;
  }
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7
N, K = map(int, readline().split())
A = list(map(int, readline().split()))
A.sort()

f = [1]
for i in range(10**5):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

ans = 0
for i in range(N-K+1):
    ans += (A[-1-i] - A[i]) * nCr(N-1-i, K-1)
    ans %= MOD
print(ans)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

ll maxn=100005;
vector<vector<pll>> G;
vector<bool> flgs;

void dfs(ll v, ll p){
  
  for(auto e: G[v]){
    ll nv=e.first;
    ll cost=e.second;
    if(nv==p) continue;
    if(cost%2==0){
      flgs[nv]=flgs[v];
    }else{
      flgs[nv]=!flgs[v];
    }
    dfs(nv,v);
  }
  return;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  G.resize(n);
  flgs.resize(n);
  rep(i,n-1){
    ll u,v,w; cin>>u>>v>>w;
    u--,v--;
    G[u].push_back(pll(v,w));
    G[v].push_back(pll(u,w));
  }
  dfs(0,-1);
  rep(i,n){
    if(flgs[i]) puts("0");
    else puts("1");
  }
}

Measured memory_bytes: 10112
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (a, b) = (iter.next().unwrap(), iter.next().unwrap());
    println!("{} {}", a*b, (a+b)*2);
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<long long>arr(3);
  cin >> arr[0] >> arr[1] >> arr[2];
  if(arr[0]%2==0||arr[1]%2==0||arr[2]%2==0){
    cout << 0 << endl;
  }else{
    sort(arr.begin(), arr.end());
    long long n = arr[0]*arr[1];
    cout << n << endl;
  }
}

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

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

int N;
int P[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,2*N) cin>>P[i];
	sort(P,P+2*N);
	reverse(P,P+2*N);
	
	double ret=0;
	FOR(i,2*N) {
		ret+=(2.0*N-(i+1))/(2.0*N-1)*P[i];
	}
	_P("%.12lf\n",ret);
}


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


Measured memory_bytes: 1024
N, M = map(int, input().split())
if M == 1:
  print('IMPOSSIBLE')
else:
  L = [0 for i in range(N-1)]
  L.insert(0, [])
  for i in range(M):
    v = list(map(int, input().split()))
    if v[0] == 1:
      L[0].append(v[1])
    else:
      if v[1] >= L[v[0]-1]:
        L[v[0]-1] = v[1]
  c = 0
  for i in range(len(L[0])):
    if L[L[0][i]-1] == N:
      c += 1
      break
  if c == 0:
    print('IMPOSSIBLE')
  else:
    print('POSSIBLE')

Measured memory_bytes: 11840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll n,k;
   cin>>n>>k;
   ll w[n],v[k];
   for(ll i=0;i<n;i++)
   {
       cin>>w[i]>>v[i];
   }
   ll dp[n+1][k+1];
   for(ll i=0;i<=n;i++)
   {
       for(ll j=0;j<=k;j++)
       {
       if(i==0 || j==0)
       dp[i][j]=0;
      else  if(j>=w[i-1])
           dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
           else
           dp[i][j]=dp[i-1][j];
       }
       
   }
   
   cout<<dp[n][k]<<endl;
   
}


Measured memory_bytes: 79104
n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n
for _ in range(m):
    p, s = input().split()
    if s == 'AC':
        ac[int(p) - 1] = 1
    elif ac[int(p) - 1] == 0:
        wa[int(p) - 1] += 1
for i in range(n):
    if ac[i] == 0:
        wa[i] = 0
print(sum(ac), sum(wa))

Measured memory_bytes: 10372
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

typedef pair<double, double> XY;

bool para(XY p, XY q) {
    double k;
    if (p.first == 0 && q.first == 0) return true;
    if (p.first == 0 || q.first == 0) return false;
    else k = q.first / p.first;
    if ((abs(p.second * k - q.second) * 1000000000000) < 1) return true;
    return false;
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        double ax, ay, bx, by, cx, cy, dx, dy;
        cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
        XY AB = make_pair(ax-bx, ay-by);
        XY CD = make_pair(cx-dx, cy-dy);
        if (para(AB, CD)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
	int n,d=0,a=0;
	cin>>n;
	int p[n];
	for(int i=0;i<n;i++){
	    cin>>p[i];
	}
	for(int i=0;i<n;i++){
	    a+=p[i];
	    d=max(d,p[i]);
	}
	cout<<a-d/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
  ll s; cin >> s;

  ll a = (ll)floor(sqrt(s));
  ll b = a * a < s ? a + 1 : a;
  if(a * b < s) a++;

  const ll diff = a * b - s;

  cout << 0 << " " << 0 << " "
       << a << " " << 1 << " "
       << diff << " " << b << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

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

    ll n, a, b; cin >> n >> a >> b;
    ll arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];

    ll sum = 0;
    for(int i=0; i<n-1; i++)
        sum += min((arr[i+1]-arr[i])*a, b);

    cout << sum;
    return 0;
}


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

int32_t main()
{

	int a, b;
	cin >> a >> b;
	int ans = 0, outelt = 1;

	while (outelt < b)
	{
		--outelt;
		outelt += a;
		++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
#define mp make_pair
#define pb push_back
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll x;cin>>x;
    if(x<100 or x>(x/100)*105)
        cout<<0<<endl;
    else
        cout<<1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

struct vertex {
	vi e;
	bool vis = 0;
	int R = 0;
};

int n, m;
graph G;
vi sorted;

bool in() {
	scanf("%d %d", &n, &m);
	G.resize(n);
	sorted.reserve(n);
	rep(i, 0, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		G[a].e.pb(b);
	}
	
	return true;
}

void toposort(int v) {
	G[v].vis = 1;
	for(int u : G[v].e)
		if(!G[u].vis)
			toposort(u);
	sorted.pb(v);
}

ll solve() {
	
	rep(v, 0, n)
		if(!G[v].vis)
			toposort(v);
	
	reverse(bend(sorted));
	
	for(auto v : sorted)
		for(auto u : G[v].e)
			maxe(G[u].R, G[v].R+1);
	
	ll R = 0;
	rep(i, 0, n)
		maxe(R, G[i].R);
		
	return R;
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


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

int	main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int64_t cnt = 0;
    for (int r = 0; R * r <= N; ++r) {
        for (int g = 0; R * r + G * g <= N; ++g) {
            if ((N - (R * r + G * g)) % B == 0)
                ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        int g = Integer.parseInt(sc.next());
        int[] p = new int[d];
        int[] c = new int[d];

        for (int i = 0; i < d; i++) {
            p[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }

        int res = Integer.MAX_VALUE;
        for (int i = 0; i < (1 << d); i++) {
            int point = 0;
            int count = 0;
            for (int j = 0; j < d; j++) {
                if((1 & i >> j) == 1) {
                    point += p[j] * (100 * (j+1)) + c[j];
                    count += p[j];
                }
            }
            if (g <= point) {
                res = Math.min(res, count);
            }else  {
                for (int j = d - 1; j >= 0; j--) {
                    if (( 1 & i >> j) == 1) {
                        continue;
                    }
                    for (int k = 0; k < p[j]; k++) {
                        if (g <= point) {
                            break;
                        }
                        point += 100 * (j + 1);
                        count++;
                    }
                }
            }
            if(g <= point) {
                res = Math.min(res, count);
            }
        }
        System.out.println(res);
    }
}


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

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

using mint = static_modint<998244353>;

int main() {
  ll n;
  cin >> n;
  vector<ll> h(2 * n);
  rep(i, 2 * n) cin >> h[i];
  sort(h.begin(), h.end());
  vector<mint> f(2 * n + 1), ff(2 * n), finv(2 * n + 1);
  f[0] = ff[0] = ff[1] = finv[0] = 1;
  repr(i, 1, 2 * n + 1) {
    f[i] = f[i - 1] * i;
    finv[i] = finv[i - 1] / i;
  }
  repr(i, 2, 2 * n) ff[i] = ff[i - 2] * i;
  auto fbps_cp = [](const vector<mint>& a, const vector<mint>& b) { return a.size() > b.size(); };
  priority_queue<vector<mint>, vector<vector<mint>>, decltype(fbps_cp)> fbps(fbps_cp);
  fbps.push(vector<mint>({1}));
  ll _fs = 0;
  rep(i, 2 * n) {
    if (i + 1 >= 2 * n || h[i] != h[i + 1]) {
      ll _fw = i + 1 - _fs;
      if (_fw >= 2) {
        vector<mint> _fbs(_fw / 2 + 1);
        _fbs[0] = 1;
        repr(j, 1, _fw / 2 + 1) {
          _fbs[j] = f[_fw] * finv[j * 2] * finv[_fw - j * 2] * ff[j * 2 - 1];
        }
        fbps.push(move(_fbs));
      }
      _fs = i + 1;
    }
  }
  while (fbps.size() >= 2) {
    auto a = fbps.top();
    fbps.pop();
    auto b = fbps.top();
    fbps.pop();
    fbps.push(convolution(move(a), move(b)));
  }
  auto forbidden = fbps.top();
  mint ans = 0;
  rep(i, n + 1) {
    if (i >= forbidden.size()) break;
    mint counts = forbidden[i];
    mint v = counts * (i == n ? 1 : ff[2 * n - 1 - i * 2]);
    if (i % 2 == 0) {
      ans += v;
    } else {
      ans -= v;
    }
  }
  cout << ans.val() << endl;
}


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

namespace _0024
{
    class Program
    {
        static void Main(string[] args)
        {
            double v = 0;
            while ((double.TryParse(Console.ReadLine(),out v)))
            {
                double t = v / 9.8;
                double y = 4.9 * t * t;
                double n = Math.Ceiling((y + 5) / 5);

                Console.WriteLine(n);
            }
        }
    }
}



Measured memory_bytes: 13840
#include <bits/stdc++.h>
using namespace std;
using Long = __int128_t;

istream &operator>>(istream &i, __int128_t &x) {
    x = 0;
    string s;
    i >> s;
    int N = int(s.size()), k = 0;
    if (s[0] == '-') k++;
    for (; k < N; k++) x = (x * 10 + s[k] - '0');
    if (s[0] == '-') x = -x;
    return i;
}

ostream &operator<<(ostream &o, __int128_t x) {
    if (x == 0) return o << 0;
    if (x < 0) o << '-', x = -x;
    deque<int> ds;
    while (x) ds.push_front(x % 10), x /= 10;
    for (int d : ds) o << d;
    return o;
}

int t1, t2;
long long a1, a2, b1, b2;

Long a_step(long long n) {
    if (n % 2 == 0) {
        return (Long)1 * t1 * a1 * n / 2 + (Long)1 * t2 * a2 * n / 2;
    } else {
        return (Long)1 * t1 * a1 * (n + 1) / 2 + (Long)1 * t2 * a2 * (n - 1) / 2;
    }
}

Long b_step(long long n) {
    if (n % 2 == 0) {
        return (Long)1 * t1 * b1 * n / 2 + (Long)1 * t2 * b2 * n / 2;
    } else {
        return (Long)1 * t1 * b1 * (n + 1) / 2 + (Long)1 * t2 * b2 * (n - 1) / 2;
    }
}

int ord(Long a, Long b) {
    if (a == b) return 0;
    return a < b ? -1 : 1;
}

int ord_step(long long n) { return ord(a_step(n), b_step(n)); }

bool check(long long n) { return ord(b_step(n), a_step(n)) != ord(b_step(n - 1), a_step(n - 1)); }

constexpr int nax = 10000000;

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

    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
        cout << "infinity" << endl;
        return 0;
    }

    int start = ord_step(1);
    for (int i = 2; i < nax; i++) {
        int now = ord_step(i);
        if (now == 0) {
            cout << i - 1 << endl;
            return 0;
        }
        if (start == now) {
            cout << i - 2 << endl;
            return 0;
        }
        start = now;
    }

    long long ok = 0, ng = 1e18;
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    assert(ng != 1e18);

    long long hoge = max(10LL, ok - nax);
    start = ord_step(hoge);
    for (long long i = hoge + 1; i < ok + nax; i++) {
        int now = ord_step(i);
        if (now == 0) {
            cout << i - 1 << endl;
            return 0;
        }
        if (start == now) {
            cout << i - 2 << endl;
            return 0;
        }
        start = now;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  string t;cin>>t;
  int l=t.length();
  rep(i,l){
    if(t[i]=='?')t[i]='D';
  }
  cout<<t<<"\n";
  return 0;
}


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

int main() {
  int N,K;
  int p[1000];
  int answer = 0;
  
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }
  
  sort(p, p + N);
  
  for (int i = 0; i < K; i++){
    answer += p[i];
  }
  
  cout << answer << endl;

}


Measured memory_bytes: 3592
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,K = LI()
h = sorted([I() for _ in range(N)])
ans = float('INF')
for i in range(N-K+1):
    ans = min(h[i+K-1]-h[i],ans)
print(ans)


Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main(){
  int n;
  int ans = 0;
  cin >> n;
  int d[n];
  REP(i,n)cin >> d[i];
  REP(i,n){
    FOR(j,i+1,n){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> G(N);
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    --L;
    --R;
    G[L].emplace_back(R, D);
    G[R].emplace_back(L, -D);
  }
  vector<int> dist(N);
  vector<bool> used(N, false);
  bool res = true;
  for (int i = 0; i < N; i++) {
    if (used[i]) {
      continue;
    }
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (auto e: G[v]) {
        int u = e.first, d = e.second;
        if (used[u]) {
          if (dist[v] + d != dist[u]) {
            cout << "No" << endl;
            return 0;
          }
        } else {
          used[u] = true;
          dist[u] = dist[v] + d;
          q.push(u);
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

signed main(){
	int N,L;cin>>N>>L;
	vector<string> S(N);
	for(int i=0;i<N;i++)cin>>S[i];
	sort(S.begin(),S.end());
	string ans="";
	for(int i=0;i<N;i++)ans+=S[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = 3 * TEN(18) + 10;
const int mod = 998244353;

struct SegTree { // 区間min,max
	int n;
	vector<int> Max;
	vector<int> Min;
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		Max.resize(2 * n);
		Min.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; ++i) {
			Max[i] = -inf;
			Min[i] = inf;
		}
	}
	void update(int idx, int val) {
		idx += n - 1;
		Min[idx] = val;
		Max[idx] = val;
		while (idx > 0) {
			idx = (idx - 1) / 2;
			Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
			Max[idx] = max(Max[idx * 2 + 1], Max[idx * 2 + 2]);
		}
	}
	int get_min(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のmin
		if (r == -1) r = n;
		if (r <= a || b <= l) return inf;
		if (a <= l && r <= b) return Min[k];
		int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	int get_max(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のmax
		if (r == -1) r = n;
		if (r <= a || b <= l) return -inf;
		if (a <= l && r <= b) return Max[k];
		int vl = get_max(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_max(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
};


int N;
vector<pii> robots;
int dp[200010];
SegTree st;

signed main()
{
	cin >> N;

	rep(i, N) {
		int x, d; cin >> x >> d;
		robots.PB(x, d);
	}

	robots.PB(inf, 0);
	sort(all(robots));

	st.init(N + 5);

	st.update(N - 1, N - 1);

	dp[N] = 1;
	for (int i = N - 1; i >= 0; --i) {
		dp[i] += dp[i + 1];
		dp[i] %= mod;

		pii r = robots[i];

		int distant_idx = lower_bound(all(robots), pii(r.fst + r.scd, 0)) - begin(robots) - 1;
		int nxt = max(st.get_max(i, distant_idx + 1), distant_idx) + 1;

		dp[i] += dp[nxt];
		dp[i] %= mod;

		st.update(i, max(distant_idx, st.get_max(i, distant_idx + 1)));
	}

	cout << dp[0] << endl;
}




Measured memory_bytes: 14188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

class UnionFind {
public:
  VI par, rank, num;
  UnionFind(int n) {
    par = VI(n); iota(par.begin(), par.end(), 0);
    rank = VI(n, 0);
    num = VI(n, 1);
  }
  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) { return; }
    if (rank[x] < rank[y]) {
      par[x] = y;
      num[y] += num[x];
    } else {
      par[y] = x;
      num[x] += num[y];
      if (rank[x] == rank[y]) { rank[x]++; }
    }
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int count(int x) {
    return num[par[x]];
  }
};

int N, K, L;
map<P, int> ans;

signed main() {
  cin >> N >> K >> L;
  UnionFind uf1(N);
  REP (i, K) {
    int p, q;
    cin >> p >> q; p--; q--;
    uf1.unite(p, q);
  }
  UnionFind uf2(N);
  REP (i, L) {
    int r, s;
    cin >> r >> s; r--; s--;
    uf2.unite(r, s);
  }

  REP (i, N) {
    ans[P(uf1.find(i), uf2.find(i))]++;
  }
  REP (i, N) {
    cout << ans[P(uf1.find(i), uf2.find(i))] << endl;
  }
}


Measured memory_bytes: 21120
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

f = [0]*(n)
x = 0
for i in range(n):
    f[i] = x
    if s[i:i+2] == "AC":
        x += 1
        
for l, r in lr:
    print(f[r-1] - f[l-1])

Measured memory_bytes: 68824
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var N = +o.getValue(0);

    var result = Array(N).fill(0);
    for(var x = 1; 100 > x; x++) {
        for(var y = 1; 100 > y; y++) {
            for(var z = 1; 100 > z; z++) {
                var n = x**2 + y**2 + z**2 + x*y + x*z + y*z;
                if (N >= n) {
                    result[n - 1] += 1;
                }
            }
        }
    }

    return result.join('\n');
}


Measured memory_bytes: 32356
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
  l n,k;
  cin>>n>>k;
  l a[n];
  for(l i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  if(n<=k)
    cout<<0<<endl;
  else{
    l sum=0;
  for(l i=0;i<n-k;i++)
  {
    sum+=a[i];
  }
  cout<<sum<<endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long ll;

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

    int cnt = 0;
    for (int i = 1; i <= a; i++)
    {
        if (i == a)
        {
            for (int j = 1; j <= min(b, 12); j++)
            {
                if (i == j)
                    cnt++;
            }
        }
        else
        {
            for (int j = 1; j <= 12; j++)
            {
                if (i == j)
                    cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
Scanner sc=new Scanner(System.in);
    int sx=sc.nextInt();
    int sy=sc.nextInt();
    int tx=sc.nextInt();
    int ty=sc.nextInt();
    int h=ty-sy;
    int w=tx-sx;
    StringBuilder sb=new StringBuilder("");
    for(int i=0;i<h;i++){
sb.append("U");
    }
    for(int i=0;i<w;i++){
sb.append("R");
    }
for(int i=0;i<h;i++){
sb.append("D");
}for(int i=0;i<w+1;i++){
sb.append("L");
}for(int i=0;i<h+1;i++){
sb.append("U");
}for(int i=0;i<w+1;i++){
sb.append("R");
}sb.append("D");
    sb.append("R");
    for(int i=0;i<h+1;i++){
sb.append("D");
    }for(int i=0;i<w+1;i++){
sb.append("L");
    }sb.append("U");
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 36308
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
  int n;
  int s[1000];
  long double sum;
  long double m;
  long double a;
  int i;
  
  while(1)
  {
    cin >> n;
    if(n==0)
      break;
      
    for(i=1;i<=n;i++)
    {
      cin >> s[i];
      sum+=s[i];
    }
    
    m=sum/n;
    
    
    for(i=1;i<=n;i++)
    {
      a+=(s[i]-m)*(s[i]-m);
    }
    
    a=sqrt(a/n);
    cout << fixed << setprecision(6) << a << "\n";
    
    sum=0;
    a=0;
  }
}

Measured memory_bytes: 1248
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int count=0;
  		int[] h=new int[n];
		for(int c=0;c<n;c++){
    		h[c]=sc.nextInt();
            if(c==0){
             count+=h[c];
            }else if(h[c-1]<h[c]){
             count+=h[c]-h[c-1];
            }
    	}
        
    	System.out.println(count);
    }
}


Measured memory_bytes: 35744
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <sstream>

using namespace std;


int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    
    string result = "Good";
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i+1]) {
            result = "Bad";
            break;
        }
    }
    
    cout << result << endl;
    
    return 0;
}



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

using namespace std;

#define EPS (1e-10)

class Point {
public:
	double x, y;
	Point(double x, double y) :
			x(x), y(y) {
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}

	double norm() {
		return x * x + y * y;
	}
};

double dot(Point p1, Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}

double cross(Point p1, Point p2) {
	return p1.x * p2.y - p1.y * p2.x;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ON_SEGMENT = -2;
static const int ONLINE_FRONT = 0;

int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0;
	Point b = p2 - p0;
	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS)
		return CLOCKWISE;
	if (dot(a, b) < -EPS)
		return ONLINE_BACK;
	if (a.norm() < b.norm())
		return ONLINE_FRONT;

	return ON_SEGMENT;
}

int main() {

	int p0x, p0y, p1x, p1y;
	scanf("%d %d %d %d", &p0x, &p0y, &p1x, &p1y);
	Point p0(p0x, p0y);
	Point p1(p1x, p1y);

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int p2x, p2y;
		scanf("%d %d", &p2x, &p2y);
		Point p2(p2x, p2y);

		switch (ccw(p0, p1, p2)) {
		case COUNTER_CLOCKWISE:
			cout << "COUNTER_CLOCKWISE" << endl;
			break;
		case CLOCKWISE:
			cout << "CLOCKWISE" << endl;
			break;
		case ONLINE_BACK:
			cout << "ONLINE_BACK" << endl;
			break;
		case ON_SEGMENT:
			cout << "ON_SEGMENT" << endl;
			break;
		case ONLINE_FRONT:
			cout << "ONLINE_FRONT" << endl;
			break;
		default:
			break;
		}

	}

	return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>
#include <iostream>
using namespace std;

long int max(long int a, long int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

long int min(long int a, long int b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}

int main(void){
  int n;
  long int *array;
  cin >> n;
  array = new long int[n];
  for(int i=0; i<n; i++){
    cin >> array[i];
  }
  long int minv = array[0];
  long int maxv = -10000000000;
  for(int j=1; j<n; j++){
    maxv = max(maxv, array[j]-minv);
    minv = min(minv, array[j]);
  }
  printf("%ld\n", maxv);
  return 0;
}



Measured memory_bytes: 4764
"""
セグメント木
func：二項演算の関数（モノイドである必要あり）
e：単位元（モノイドにおける）
update, find, bisect, 全てにおいて, 1-indexとなっている。
(大抵の場合、Atcoderの問題文の表記のままの値を、メソッドに代入すれば良い)
"""
class SegmentTree:
    def __init__(self, n, func, e, arrange=None):
        self.init(n)
        self.func = func
        self.e = e
        self.make_arrange(arrange)
    
    def init(self, n):
        self.inf = pow(2, 32)
        self.n = n
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
    
    def make_arrange(self, arrange):
        self.set_arrange(arrange)
        self.construct(arrange)

    def set_arrange(self, arrange):
        if arrange == None:
            self.segment = [self.e]*(self.size)
            return
        self.segment = [0]*(self.N) + arrange + [self.e]*(self.size-self.N-self.n)
    
    def construct(self, arrange):
        if arrange == None:
            return
        for i in range(self.N-1, 0, -1):
            self.segment[i] = self.func(self.segment[2*i], self.segment[2*i+1])
    
    def update(self, i, x):
        i += (self.N - 1)
        self.segment[i] = x
        while i > 1:
            i = i//2
            self.segment[i] = self.func(self.segment[2*i], self.segment[2*i+1])
    

    def count(self, l, r):
        res = self.e
        l += self.N-1
        r += self.N
        while r > l:
            if l & 1:
                res = self.func(res, self.segment[l])
                l += 1
            if r & 1:
                r -= 1
                res = self.func(res, self.segment[r])
            l >>= 1
            r >>= 1
        return res
    

    def bisect_sub(self, a, b, k, l, r, x):
        if r <= a or b <= l:
            return b+1
        if self.segment[k] < x:
            return b+1
        if k >= self.N:
            return r
        
        find_l = self.bisect_sub(a, b, 2*k, l, (l+r)//2, x)
        if find_l <= b:
            return find_l

        find_r = self.bisect_sub(a, b, 2*k+1, (l+r)//2, r, x)
        return find_r

    def bisect(self, l, r, x):
        return self.bisect_sub(l-1, r, 1, 0, self.size-self.N, x)
    

def main():
    n, q = map(int, input().split())
    p = list(map(int, input().split()))
    seg = SegmentTree(n, max, 0, arrange=p)

    res = []
    for i in range(q):
        a, b, c = list(map(int, input().split()))
        if a == 1:
            seg.update(b, c)
        elif a == 2:
            ans = seg.count(b, c)
            res.append(ans)
        else:
            ans = seg.bisect(b, n, c)
            res.append(ans)

    print(*res, sep="\n")
            

    
if __name__ == "__main__":
    main()




Measured memory_bytes: 114124
import math
x, n = map(int, input().split())
p = list(map(str, input().split()))
dis = {}
for i in p:
    dis[i] = True

res = -1
mins = 100
for i in range(200):
    if not dis.get(str(i)) and math.fabs(i - x) < mins:
        res = i
        mins = math.fabs(i - x)
print(res)


Measured memory_bytes: 9188