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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    string s,t;
    cin>>s>>t;
    bool check=true; 
    REP(i,0,s.size()){
        if(s[i]!=t[i]) check=false;
    }
    cout<<(check?"Yes":"No")<<endl;
}

Measured memory_bytes: 3612
//author: Harsh :)
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 100007
using namespace std;
int main() {
  fastio;
  ll n = 0, m = 0, t = 0;
  cin >> n >> m >> t;
  char ar[n][m];
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < m; ++j) {
      cin >> ar[i][j];
    }
  }
  ll ans = 0;
  for (ll i = 0; i < (1 << n); ++i) {
    for (ll j = 0; j < (1 << m); ++j) {
      ll curr_sum = 0;
      for (ll k = 0; k < n; ++k) {
        for (ll l = 0; l < m; ++l) {
          if ((i & (1 << k)) or (j & (1 << l))) continue;
          else {
            if (ar[k][l] == '#')
              ++curr_sum;
          }
        }
      }
      ans += (curr_sum == t);
    }
  }
  cout << ans;
}

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

using namespace std;

typedef long long ll;

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

	int a, p;
	cin >> a >> p;

	cout << (a * 3 + p) / 2 << endl; 


}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*M]

class UnionFind:
    def __init__(self,N):
        self.Parent = list(range(N))
        self.size = [1]*N
    def get_Parent(self,n):
        if self.Parent[n] == n:return n
        p = self.get_Parent(self.Parent[n])
        self.Parent[n] = p
        return p
    def get_size(self,n):
        return self.size[self.get_Parent(n)]
    def merge(self,x,y):
        x = self.get_Parent(x)
        y = self.get_Parent(y)
        if x!=y:
            self.size[x] += self.size[y]
            self.Parent[y] = x
            return True
        return False
    def is_united(self,x,y):
        return self.get_Parent(x)==self.get_Parent(y)

ans = [0]
T = UnionFind(N)
for a,b in AB[::-1]:
    a-=1;b-=1
    ans.append(ans[-1])
    A = T.get_size(a)
    B = T.get_size(b)
    if T.merge(a,b):
        C = T.get_size(a)
        ans[-1] += (C*(C-1)-A*(A-1)-B*(B-1))//2

a0 = ans[-1]
for o in ans[-2::-1]:print(a0-o)

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

#define INF 1234567890
#define ll long long

int N;

bool ok(string &s)
{
	bool chk[26] = {0, };
	for(int i=0; i<s.size(); i++)
		chk[s[i]-'a']=true;

	int ty = 0;
	for(int i=0; i<26; i++)
	{
		if (ty==0 && chk[i]==false)
			ty = 1;
		else if (ty==1 && chk[i]==true)
			return false;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	string s(N, 'a'), E;
	for(int i=0; i<N; i++) E += ('a'+i);
	while(s != E)
	{
		cout << s << "\n";
		for(int i=N-1; i>=0; i--)
		{
			s[i] = s[i]+1;
			if (ok(s))
			{
				for(int j=i+1; j<N; j++)
					s[j] = 'a';
				break;
			}
			s[i] = s[i]-1;
		}
	}
	cout << E;
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

  ll res=0;
  bool f=false;
  for(int i=0;i<n;i++){
    cin>>x;
    if(x==0){
      f=false;
      continue;
    }
    if(f) x++;
    res+=x/2;
    if(x%2==1) f=true;
    else f=false;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
int main()
{
	IOS();

	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	int a[10];
	int b[10];
	int c[10];
	memset(a, 0, sizeof(a));
	for(int i=0; i<n; i++)
	{
		if(a[s[i]-'0']) continue;
		a[s[i]-'0']=1;
		memset(b, 0, sizeof(b));
		for(int j=i+1; j<n; j++)
		{
			if(b[s[j]-'0']) continue;
			b[s[j]-'0']=1;
			memset(c, 0, sizeof(c));
			for(int l=j+1; l<n; l++)
			{
				if(c[s[l]-'0']) continue;
				c[s[l]-'0']=1;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  rep(n) cin >> v[i];
  int acum = accumulate(all(v), 0);
  if (acum > n) {
    cout << -1 << endl;
    return;
  }
  cout << n - acum << endl;

}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 7100
import bisect

s = input()
k = int(input())

alpha_list = [chr(i) for i in range(97, 97+26)] #["a","b",...."c"]
dic = []
for i in range(len(s)):
    dic = sorted(dic)
    if k < bisect.bisect_left(dic,s[i]):
        continue
    for j in range(i+1, min(i+6, len(s)+1)):
        s0 = s[i:j]
        
        if s0 not in dic:
            dic.append(s0)

print(sorted(dic)[k-1])

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

using namespace std;

void solve()
{
    int n;
    string s, t;
    cin >> n;
    int s1 = 0, s2 = 0;
    while (n--)
    {
        cin >> s >> t;
        if (s == t)
        {
            s1++, s2++;
        }
        else if (s < t)
        {
            s2 += 3;
        }
        else
        {
            s1 += 3;
        }
    }
    cout << s1 << ' ' << s2 << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3148
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

long double count(Int point, Int goal){
    long double count=0;
    long double pow=1;
    while(point< goal){
        point *= 2;
        count++;
    }
    rep(i,count){
        pow*=2;
    }
    return pow;
}

int main() {
    long double N,K;
    cin >> N >> K;
    vector<long double> a;
    long double ans =0;

    REP(i,1,N+1){
        long double base = (1.0/N);
        long double plus;
        long double pow_count = count(i,K);
        if(pow_count == 0){
            a.push_back(base);
        }else{
            plus = 1/pow_count;
            a.push_back(base*plus);
        }
    }

    rep(i,a.size()){
        ans += a[i];
    }

    cout << setprecision(12) <<ans << endl;

    return 0;
}

Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(1000000)
def solve():
  n = int(input())
  s = input()
  ans = ""
  for i in range(len(s)):
    temp = 0
    if ord(s[i])+n > 90:
      temp = 26
    ans += chr(ord(s[i])+n-temp)
  print(ans)
solve()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using Graph = vector<vector<int>>;

typedef long long LL;
typedef long double LD;
const int mod = 1000000007;

int N, Q;
Graph G;

void dfs(int v, int p, vector<long long> &res) {
    if (p != -1) res[v] += res[p];
    for (auto e : G[v]) {
        if (e == p) continue;
        dfs(e, v, res);
    }
}

int main() {
    cin >> N >> Q;
    G.assign(N, vector<int>());
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<long long> val(N, 0);
    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        --p;
        val[p] += x;
    }
    dfs(0, -1, val);
    for (auto v : val) cout << v << " ";
    cout << endl;
}

Measured memory_bytes: 24320
n,m,c = map(int,input().split())
b = [int(x) for x in input().split()]
l = []
tmp = []
judge = c
for i in range(n):
  tmp = [int(x) for x in input().split()]
  l.append(tmp)
count = 0
for i in range(n):
  for k in range(m):
    judge += b[k]*l[i][k]
  if judge > 0:
    count += 1
  judge = c
print(count)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<ll> v(n), acc(n);
  rep(i, 0, n) {
    cin >> v[i];
    if (i == 0)
      acc[i] = v[i];
    else
      acc[i] = acc[i - 1] + v[i];
  }

  ll cor = 0, a1 = 0, a2 = 0;
  rep(i, 0, n) {
    ll add = abs(acc[i] + cor) + 1;
    if (i & 1 && acc[i] + cor >= 0) {
      a1 += add;
      cor -= add;
    } else if (!(i & 1) && acc[i] + cor <= 0) {
      a1 += add;
      cor += add;
    }
  }

  cor = 0;
  rep(i, 0, n) {
    ll add = abs(acc[i] + cor) + 1;
    if (i & 1 && acc[i] + cor <= 0) {
      a2 += add;
      cor += add;
    } else if (!(i & 1) && acc[i] + cor >= 0) {
      a2 += add;
      cor -= add;
    }
  }
  cout << min(a1, a2) << endl;
}


Measured memory_bytes: 1792
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun shiftSumAbs(a: List<Int>, shift: Int) = a.map { Math.abs(it - shift).toLong() }.sum()

fun main(args: Array<String>) {
    val N = readInts()[0]
    val A = readInts()
    val shifted = A.mapIndexed { index, num -> num - index - 1 }
    println(shiftSumAbs(shifted, shifted.sorted()[N / 2]))
}

Measured memory_bytes: 84940
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N, M = LI()
A = LI()

pq = PriorityQueue()
for a in A:
    pq.put((-a, a))

for i in range(M):
    val = pq.get()[1]
    val = math.floor(val/2)
    pq.put((-val, val))

ans = 0
while not pq.empty():
    ans += pq.get()[1]
print(ans)


Measured memory_bytes: 23032
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print( N//2+1 if N%2 != 0 else N//2)

Measured memory_bytes: 5148
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int ans = p + q + r;
	ans -= max(p, max(q, r));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll MOD=1000000007;

int main(){
	ll N;
    cin >> N;
    ll N2=sqrt(N);
    ll K;
    cin >> K;
    vector<vector<ll>> dp(K+1, vector<ll>(2*N2+2,0));
    for(ll i=1;i<=N2;i++){
        dp[1][i]=1
    ;}
    dp[1][N2+1]=N/N2-N2;
    for(ll i=N2+2;i<=2*N2;i++){
        dp[1][i]=N/(2*N2+1-i)-N/(2*N2+2-i)
    ;}
    for(ll i=2;i<=K;i++){
        ll sum=0;
        for(ll j=2*N2;j>=1;j--){
            sum+=dp[i-1][2*N2+1-j];
            dp[i][j]=(sum*dp[1][j])%MOD
        ;}
    ;}
    ll ans=0;
    for(ll i=1;i<=2*N2;i++){
        ans+=dp[K][i];
        ans%=MOD;
    ;}
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 50816
N = int(input())
A = list(map(int,input().split()))
total = 1
if 0 < A.count(0):
    print(0)
else:
    for i in range(N):
        total *= A[i]
        if 10 ** 18 < total:
            break
    if 10**18 < total:
        print("-1")
    else:
        print(total)

Measured memory_bytes: 21788
#include <iostream>

int main()
{
	int a[10] = { 0 };
	int n, nrs = 0, special = 0;
	std::cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		int x;
		std::cin >> x;
/*		for (int j = 400; j <= 3200; j += 400)
			if (x < j)
			{
				++a[j / 400];
				if (a[j / 400] == 1)
					++nrs;
				break;
			}*/
		if (x > 3199)
			++special;
		else
		{
			++a[x / 400];
			if (a[x / 400] == 1)
				++nrs;
		}
	}
	
	std::cout << std::max(nrs, 1)<< " ";
	std::cout << nrs + special;
}

Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int n;

void dfs(string s,char c)
{
	if(s.size()==n)
		cout<<s<<endl;
	else{
		for(char i='a';i<=c;i++)
		{
			dfs(s+i,((i==c)?(char)(c+1):c));
		}
	}
}
int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	dfs("",'a');
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  if (a == b) {
    if (b == c) d = 1;
    else d = 2;
  }
  else {
    if (b == c) d = 2;
    else {
      if (a == c) d = 2;
      else d = 3;
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }
  if(b=='C'){
    cout<<'G'<<endl;
  }
  if(b=='G'){
    cout<<'C'<<endl;
  }
  if(b=='T'){
    cout<<'A'<<endl;
  }
}

Measured memory_bytes: 256
n = input()
n = int(n)
seq = input().split()
sumNum = 0
minNum = 1000000
maxNum = -1000000
for numT in seq:
 num = int(numT)
 if(num > maxNum):
  maxNum = num
 if(num < minNum):
  minNum = num
 sumNum+=num
print(minNum,maxNum,sumNum)


Measured memory_bytes: 6328
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
before = -100
for i in a:
    i -= 1
    if i == before + 1:
        ans += c[before]
    before = i
    ans += b[i]
print(ans)

Measured memory_bytes: 9196
n = int(input())
ar = list(map(int, input().split()))

try:
	assert 3 <= n <= 10
	assert len(ar) == n
	assert (1 <= min(ar)) and (max(ar) <= 100)
except:
	print("No")
else: 
	if max(ar) < (sum(ar) - max(ar)):
	  print("Yes")
	else:
	  print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
  
int main()
{
  priority_queue<ll> q;
  ll n, fst, sec;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) {cin >> v[i]; q.push(v[i]);}
  fst = q.top();
  q.pop();
  sec = q.top();

  rep(i, n)
  {
    if(fst == v[i])
    {
      cout << sec << "\n";
    }
    else cout << fst << "\n";
  }
}

Measured memory_bytes: 4848
#include <stdio.h>

int min(int,int);

int main(){
int n,k,i,x,y,f;

scanf("%d%d",&n,&k);
for(i=0;i<k;i++){
scanf("%d %d",&x,&y);
x= x>=n/2 ? n-x+1:x;
y= y>=n/2 ? n-y+1:y;
f=(min(x,y)%3 ? min(x,y)%3:3);
printf("%d\n",f);
}

return 0;
}


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

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, p[100008], pos[100008];

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> p[i];
		pos[p[i]] = i;
	}
	
	ll ans = 0;
	set<ll> s;
	s.insert(0);
	s.insert(n+1);
	s.insert(pos[n]);
	for(ll i = n-1; i >= 1; i--){
		s.insert(pos[i]);
		auto litr = s.lower_bound(pos[i]);
		litr--;
		ll l1 = *litr;
		auto litr2 = s.lower_bound(l1);
		litr2--;
		ll l2 = (l1 == 0)? 0 : *litr2;
		ll r1 = *s.upper_bound(pos[i]);
		ll r2 = (r1 == n+1)? n+1 : *s.upper_bound(r1);
		//cout << l2 << l1 << r1 << r2 << endl;
		ans += (pos[i]-l1)*(r2-r1)*i;
		ans += (r1-pos[i])*(l1-l2)*i;
		//cout << ans << endl;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X=in();
    int ans=0;
    ans+=1000*(X/500);
    X%=500;
    ans+=5*(X/5);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad.ST
import Data.STRef
import Data.Array.ST
import Control.Monad

main :: IO ()
main = do
  s <- getLine
  putStrLn $ oddString s

oddString :: String -> String
oddString str = runST $ do
  oddStr <- newSTRef ""
  arrStr <- newListArray (0, length str - 1) str :: ST s (STUArray s Int Char)
  forM_ [0..length str - 1] $ \i ->
    if i `mod` 2 == 1
      then return ()
      else do
        c <- readArray arrStr i
        now <- readSTRef oddStr
        writeSTRef oddStr (c:now)

  reverse <$> readSTRef oddStr


Measured memory_bytes: 7548
S = int(input())

C = [[0 for j in range(i+1)] for i in range(S+1)]

C[0][0] = 1

mod = 1000000007

for i in range(1,S+1):
    for j in range(i+1):
        if j>0:
            C[i][j] += C[i-1][j-1]
        if j<i:
            C[i][j] += C[i-1][j]
        C[i][j] %= mod

ans = 0

n = 1

while S - 3*n >= 0:
    ans += C[S-2*n-1][n-1]
    ans %= mod

    n+=1

print(ans)

Measured memory_bytes: 84324
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007
#define int long long
signed main(){
    boost;
   int n;
   cin>>n;
   int arr[n];
   int cum = 0;
   for(int i=0;i<n;i++){
       cin>>arr[i];
       cum = cum^arr[i];
   }
   for(int i=0;i<n;i++){
       cout<<(cum^arr[i])<<" ";
   }
}


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

using namespace std;
int n,k,Ans[400010];
inline void putstr()
{
	int len=n;
		while(!Ans[len]) len--;
		//cout << len;
		for(int i=1;i<=len;i++) printf("%d ",Ans[i]); printf("\n");
}
int main()
{
//	freopen("read.in","r",stdin);
//	freopen("wro.out","w",stdout);
	scanf("%d%d",&k,&n);
	if(n==1)
	{
		printf("%d\n",(k+1)/2);
		return 0;
	}
	if(k==1)
	{
		for(int i=1;i<=(n+1)/2;i++)
			printf("%d ",1); printf("\n");
		return 0;
	}
	if(k&1)
	{
		int ts=n/2; 
		for(int i=1;i<=n;i++) Ans[i]=(k+1)/2;
		
		for(int i=1;i<=ts;i++)
		{
			int nw=n; while(!Ans[nw]) nw--;
			if(Ans[nw]==1) Ans[nw]=0;
			else 
			{
				Ans[nw]--;
				for(int j=nw+1;j<=n;j++) Ans[j]=k;
			}
	//		putstr();
		}
		putstr();
		return 0;
	}
	else 
	{
		printf("%d ",k/2);
		for(int i=1;i<n;i++) printf("%d ",k); printf("\n");
	}
	return 0;
}

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

string s;
const long long SZ = 1000009;
long long dp[SZ+1][2];

int main() {
  cin >> s;
  long long ans = 0, N = s.size();
  dp[0][1] = 0x3fffffff;
  for(long long i = 1; i <= N; i++) {
    long long n = s[N-i] - '0';
    if(n < 9) {
      dp[i][0] = min(dp[i-1][0] + n, dp[i-1][1] + n + 1);
      dp[i][1] = min(dp[i-1][0] + 10-n, dp[i-1][1] + 10 - (n + 1));
    } else {
      dp[i][0] = dp[i-1][0] + n;
      dp[i][1] = min(dp[i-1][0] + 10-n, dp[i-1][1] + 10 - (n + 1));
    }
  }
  cout << min(dp[N][0], dp[N][1] + 1);
}


Measured memory_bytes: 17028
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

vi LPS(vi pat)
{

    vi lps(sz(pat));
    lps[0]=0;
    ll len=0;
    ll i=1;
    while(i<sz(pat))
    {
        if(pat[i]==pat[len])
        {
            len++;
            lps[i]=len;
            i++;
        }
        else
        {
            if(len)
                len=lps[len-1];
            else
                lps[i]=0,i++;
        }
    }
    return lps;
}

vi KMP(vi pat,vi txt)
{
    vi lps=LPS(pat);
    vi ans;
    ll i=0,j=0;
    while(i<sz(txt))
    {
        if(pat[j]==txt[i]) i++,j++;
        if(j==sz(pat)) 
        {
            ans.pb(i-j+1);
            j=lps[j-1];
        }
        else if(i<sz(txt)&&txt[i]!=pat[j])
        {
            if(j)
                j=lps[j-1];
            else
                i++;
        }
    }
    return ans;
}
void solve()
{
    ll n,x;
    cin>>n;
    vi a;
    vi b;
    rep(i,0,n)
    {
        cin>>x;
        a.pb(x);
    }
    rep(i,0,n)
    {
        cin>>x;
        b.pb(x);
    }
    vi A,B;
    rep(i,0,n)
    {
        A.pb(a[i]^(a[(i+1)%n]));
        B.pb(b[i]^(b[(i+1)%n]));
    }
    rep(i,0,n-1)
    {
        A.pb(A[i]);
    }
    // cout<<KMP(B,A)<<endl;
    vi ans=KMP(B,A);
    for(auto u:ans)
    {
        cout<<u-1<<" "<<(a[u-1]^b[0])<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 21968
def d(x, y):
  return abs(x[0] - y[0]) + abs(x[1] - y[1])
n, m = map(int, input().split())
x = [tuple(map(int, input().split())) for i in range(n)]
y = [tuple(map(int, input().split())) for i in range(m)]
for i in range(n):
  p = 0
  for j in range(1, m):
    if d(x[i], y[j]) < d(x[i], y[p]):
      p = j
  print(p + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const ll INF = 1e18 + 7;

int a[N];

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

	int n;
	cin >> n;
	for (int i=0; i<n; i++)
		cin >> a[i];
	ll res = INF;
	for (int j=0; j<2; j++)
	{
		ll sum = 0;
		ll ans = 0;
		for (int i=0; i<n; i++)
		{
			sum += a[i];
			if (i % 2 == j)
			{
				if (sum <= 0)
					ans += 1 - sum, sum += 1 - sum;
			}
			else
			{
				if (sum >= 0)
					ans += sum + 1, sum -= sum + 1;
			}
		}
		res = min(res, ans);
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

double R;
signed main(){
    scanf("%lf",&R);
    double ans=2.0*R*M_PI;
    printf("%lf\n",ans);
    return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    for (size_t i = 0; i < w + 2; i++)
    {
        cout << "#";
    }
    cout << endl;
    string s;
    for (size_t i = 0; i < h; i++)
    {

        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for (size_t i = 0; i < w + 2; i++)
    {
        cout << "#";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = idx = 0
for i in range(n):
    cnt += 1
    if a[idx] == 2:
        break
    if a[a[idx] - 1] == idx + 1:
        cnt = -1
        break
    if i == n - 1:
        cnt = -1
        break
    idx = a[idx] - 1
print(cnt)

Measured memory_bytes: 7084
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try {
			Scanner scanner = new Scanner(System.in);
			int a = scanner.nextInt();
			int b = scanner.nextInt();

			Main testA = new Main();
			System.out.println(testA.plus(a, b));

			scanner.close();

		} catch (InputMismatchException e) {
			// TODO: handle exception
			System.out.println("整数を入力してください");
		}
	}

	public int plus(int a, int b) {
		if(a+b >= a-b) {
			if(a+b >= a*b) {
				return a+b;
			}else {
				return a*b;
			}
		}else {
			if(a-b > a*b) {
				return a-b;
			}else {
				return a*b;
			}
		}
	}


}



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

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

  ll d = 4 * a * b;
  ll e = (c - a - b) * (c - a - b);

  if (a + b > c) {
    cout << "No" << endl;
    return 0;
  }

  if (a + b == c) {
    cout << "No" << endl;
    return 0;
  }

  if (4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    vector<int> pts(100);
    int id, pt;
    char comma;
    while(cin >> id >> comma >> pt && (id || pt)) {
        pts[id] = pt; 
    }

    vector<int> upts;
    for (int i = 30; i >= 0; i--) {
        if(find(pts.begin(), pts.end(), i) != pts.end()) {
            upts.push_back(i);
        }
    }

    while(cin >> id) {

        int res = 1;
        for(int i = 0; i <= 30; i++) {
            if(pts[id] != upts[i]) {
                res += 1;
            } else {
                break;
            }
        }
        cout << res << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
n, x = map(int, input().split())
a = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

res = 0
for i in a:
    res = gcd(res, abs(i - x))
print(res)


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

int main() {
    double w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if (((x>=r)&&(x<=w-r))&&((y>=r)&&(y<=h-r))) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n; cin>>n;
   int pn=n;
   long long ans=0;
   if(n%2)n--;
   for(int i=1;i<=n/2;i++)
       {
           for(int j=i+1;j<=n-i;j++)
           {
               ans+=2LL;
           }
       }
       if(pn%2)
       {

           for(int i=0;i<pn-1;i++)
           {

               ans++;
           }
       }
       cout<<ans<<"\n";
        for(int i=1;i<=n/2;i++)
       {
           for(int j=i+1;j<=n-i;j++)
           {
               cout<<i<<" "<<j<<"\n";
               cout<<n-i+1<<" "<<j<<"\n";
           }
       }
       if(pn%2)
       {

           for(int i=0;i<pn-1;i++)
           {

               cout<<i+1<<" "<<pn<<"\n";
           }
       }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll cntr = 0;
  ll cntg = 0;
  ll cntb = 0;
  rep(i,s.size()) {
    if(s[i]=='R') cntr++;
    if(s[i]=='G') cntg++;
    if(s[i]=='B') cntb++;
  }
  ll ans = cntr*cntg*cntb;
  for(int i = 1; i<=(n/2); i++) {
    for(int j = 0; j+i+i<n; j++) {
      if(s[j]!=s[j+i] && s[j+i]!=s[j+i+i] && s[j+i+i]!=s[j]) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int judgeprime(long num){
  int primeflag=1,i;

  if(num%2==0){primeflag=0;}
  else if(1){
    for(i=3;i<sqrt(num)+1;i+=2){
      if( num%i==0 ){
	primeflag=0;
	break;
      }
    }
  }

  if(num==0||num==1){primeflag=0;}
  else if(num==2){primeflag=1;}

  return primeflag;

}

int main(void){
  long i,num,j=0;
  int prime[78665];

  for(i=0;i<1000000;i++){
    if(  judgeprime(i) ){
      prime[j]=i;
      j++;
    }
  }


  while( scanf("%ld",&num) != -1 ){

    for(i=0;i<78665;i++){
      if( prime[i]>num){
	printf("%ld\n",i);
	break;
      }
    }

  }

  return 0;  
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int reversed = 0;
	string s; cin >> s;

	deque<char> dq;
	for (char ch : s) dq.push_back(ch);

	int Q; cin >> Q;
	while (Q--) {
		int q; cin >> q;
		if (q == 1) reversed ^= 1;
		else {
			int f; char c;
			cin >> f >> c;
			if (f == 1) {
				if (reversed) dq.push_back(c);
				else dq.push_front(c);
			}
			else {
				if (reversed) dq.push_front(c);
				else dq.push_back(c);
			}
		}
	}

	if (!reversed) {
		for (int i = 0; i < dq.size(); i++) cout << dq[i];
	}
	else {
		for (int i = dq.size() - 1; i >= 0; i--) cout << dq[i];
	}
	return 0;
}

Measured memory_bytes: 4044
s = input().split()
A = int(s[0]) # 鬼の最初の位置
V = int(s[1]) # 鬼の速さ
s = input().split()
B = int(s[0]) # 逃げる子供の最初の位置
W = int(s[1]) # 逃げる子供の速さ
T = int(input())

AB = abs(A-B)
speed_dif = V - W

if AB == 0:
    print("YES")
elif speed_dif <= 0:
    print("NO")
else:
    time = AB / speed_dif
    if time <= T:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9204
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N;
LL Z, W;
vector<LL>a;

LL memo[2345][2];
LL dp(int turn, bool isx) {
	if (memo[turn][isx] >= 0)return memo[turn][isx];
	if (isx) {
		//差をたくさんにしたい
		LL op = (turn ? a[turn - 1] : W);//相手が持っている数
		LL score = abs(op - a.back());
		for (int i = turn + 1; i < N; ++i) {
			score = max(score, dp(i, false));
		}
		return memo[turn][isx] = score;
	}
	else {
		//差を小さくしたい
		LL op = (turn ? a[turn - 1] : Z);//相手が持っている数
		LL score = abs(op - a.back());
		for (int i = turn + 1; i < N; ++i) {
			score = min(score, dp(i, true));
		}
		return memo[turn][isx] = score;
	}
}

int main(void)
{
	cin >> N >> Z >> W;
	memset(memo, 0xff, sizeof(memo));
	for (int i = 0; i < N; ++i) {
		LL tmp; cin >> tmp;
		a.push_back(tmp);
	}
	cout << dp(0, 1) << endl;
	return 0;
}


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

set<string>se;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes";
            return;
        }
        a-=d;
        if(a<=0){
            cout<<"No";
            return;
        }
    }
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int ifprime(int nb);
int main() {
    int n;
    int readScan = scanf("%d", &n);
    int a[n];
    int count; 
    count=0;
    for(int i=0; i<n; i++)
    {
        int readScan = scanf("%d", &a[i]);
        if(a[i]==2 || a[i]==3)
            count++;  
        int prime;
        if(a[i]>3)
        {
            if(ifprime(a[i])==1)
                count++;
        }
    }
    printf("%d\n", count);
    return (EXIT_SUCCESS);
}
int ifprime(int nb)
{
      int i,  count, test,limit;
      test = count = 0;
      limit = sqrt(nb) + 1;

      if(nb == 2)
      {
          return 1;
      }

      if (nb % 2 == 0)
              test = 1;
      else{
          for (i = 3 ; i < limit && ! test; i+=2, count++)
            if (nb % i == 0)
              test = 1;
      }
      if (!test)
              return 1;
      else
              return 0;
}





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

int main()
{
    int a,n,i,j,min,max;
    long long sum;
    cin >> n;
    cin >> a;
    min = max = sum = a;
    for (i = 1; i < n; i++) {
        cin >> j;
        sum += j;
        if (max < j)
            max = j;
        if(min > j)
            min = j;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

map<ll, int> mp;
int x2 = 0, x4, x14 = 0, x24 = 0, x74 = 0;

ll comb_count(int n, int m) {
  if (m == 0)
    return 1;
  if (n == 0)
    return 0;
  return (n * comb_count(n - 1, m - 1) / m);
}

void judge(int x) {
  if (mp[x] == 2)
    x2++;
  else if (mp[x] == 4) {
    x4++;
    x2--;
  } else if (mp[x] == 14)
    x14++;
  else if (mp[x] == 24)
    x24++;
  else if (mp[x] == 74)
    x74++;
}

void prime_factor(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
      judge(i);
    }
  }
  if (n != 1) {
    mp[n]++;
    judge(n);
  }
}

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

  int n;
  cin >> n;

  rep(i, 2, n + 1) { prime_factor(i); }

  int g_four = x4 + x14 + x24 + x74;
  int g_two = x2 + g_four;
  int ans = comb_count(x4, 2) * (x2 + x4 - 2);
  ans += x14 * (x4 - 1);
  ans += x24 * (x2 + x4 - 1);
  ans += x74;
  cout << ans << endl;
}


Measured memory_bytes: 3472
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using ll = long long;
using namespace std;

constexpr ll INF = numeric_limits<ll>::max();

void solve() {
  int N;
  cin >> N;

  vector<int> v(N);
  for (int &l : v) {
    cin >> l;
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int x = i + 1; x < N; x++) {
      for (int p = x + 1; p < N; p++) {
        if (v[i] < v[x] + v[p]) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	static const double pi = acos(-1.0);
	double a , b , h , m;
	cin>> a >> b >> h >> m;
	double angle = abs(h * 30 - m * 6 + 0.5 * m);	
	cout << fixed << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(angle*pi/180));
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double x1, x2, x3, x4, y1, y2, y3, y4;
    int n;
    cin >> n;
    rep(i, n)
    {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if (abs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 0.0000000001)
        {
            OP("YES")
        }
        else
        {
            OP("NO")
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
 
  int A[3];
  
  for(int i=0; i < 3; i++){
  scanf("%d", &A[i]);
  }
    
  for(int i = 0; i < 2; i++){
   for(int j = 0; j < 2; j++){
     if(A[j] > A[j+1]){
       int tmp;
       tmp = A[j+1];
       A[j+1] = A[j];
       A[j] = tmp;
     }
   }
  }
    
  if(A[0] == 5 && A[1] == 5 && A[2] == 7){
    printf("YES");
  }else{
    printf("NO");
  }
  
  return 0;
}

Measured memory_bytes: 128
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日 10/ 8 19:56:17 2017
 * Ended  Time*  : 二 10/10 22:44:17 2017
*********************************************/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 1e5;
 
int n, m;
 
int col[MaxN + 5];
int U[MaxN + 5], V[MaxN + 5];
LL cnt[2];
vector<int>edge[MaxN + 5];
LL tot, ans;
 
void build(int u, int v) {edge[u].push_back(v);}
 
void dfs(int u, int c){
	col[u] = c;
	cnt[c]++;
	for(int i = 0; i < edge[u].size(); i++){
		int v = edge[u][i];
		if(col[v] == -1) dfs(v, c ^ 1);
	}
}
 
int main()
{
	while(~scanf("%d %d", &n, &m)){
		memset(col, -1, sizeof(col));
		for(int i = 1; i <= m; i++){
			int u, v;
			scanf("%d %d", &U[i], &V[i]);
			build(U[i], V[i]), build(V[i], U[i]);
		}
		dfs(1, 1);
		bool ok = false;
		for(int i = 1; i <= m; i++){
			int u = U[i], v = V[i];
			if(col[u] == col[v]) ok = true;
		}
		if(ok) ans = (LL)n * (LL)(n - 1LL) / 2LL;
		else ans = cnt[0] * cnt[1];
		//for(int i = 1; i <= n; i++) printf("%d ", col[i]); printf("\n");
		//printf("%d\n", ok);
		printf("%lld\n", ans - m);
	}
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using ll = long long;
const ll MOD = 1000000007;
#define rep(i,n) for (ll i=0; i < (n); i++)
using namespace std;
int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main () {
  int n;
  scanf("%d", &n);
  vector<ll> a(n+1, 0);
  rep(i,n) scanf("%lld", &a[i+1]);

  ll sum1 = accumulate(a.begin(), a.end(), 0);

  ll sum2 = 0;
  for (int i = 1; 2*i <= n - 1; i++) {
    sum2 += a[2*i];
  }

  int x = sum1 - 2*sum2;
  printf("%d ", x);
  for(int i = 2; i <= n; i++) {
    x = 2 * a[i-1] - x;
    printf("%d ", x);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long double 
#define ull unsigned long long int 
const ll pi=3.141592653589;
int main() {
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ll t1=(2*pi)/(12*60);
    ll t2=(2*pi)/(60);
    ll c1=t1*(h*60+m);
    ll c2=t2*m;
    ll ans=sqrt(a*a+b*b-2*a*b*cos(c1-c2));
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 4160