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

int main() {
    int N, K, range;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        int aRange, bRange;
        aRange = x * 2;
        bRange = (K - x) * 2;
        if (aRange < bRange) {
            range += aRange;
        } else {
            range += bRange;
        }
    } 
    cout << range << endl;
}


Measured memory_bytes: 256
import bisect
from collections import deque

N = int(input())

tops = deque() 

for i in range(N):
    a = int(input())
    p = bisect.bisect_left(tops, a)
    
    if p == 0:
        tops.appendleft(a)
    else:    
        tops[p-1] = a
        
print(len(tops))


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

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 < m2 || (m1 ==12 and m2 == 1)){
    cout << 1;
  }
  else {
    cout << 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n;
	cin >> n;
	ll tot = 0;
	vector <ll> a(n);
	rep0(i,n){
		cin >> a[i];
		tot ^= a[i];
	}

	rep0(i,n) cout << (tot^a[i]) << " ";

	return;
}

int main(){

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

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

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

using namespace std;

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

const int N = 1e5 + 5;

int n,x,a[N];

multiset <int> s;

void fail(bool ok) {
  if (ok == true) {
    cout << "Impossible\n";
    exit(0);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i];
    x = max(x,a[i]);
    s.insert(a[i]);
  }
  if (x % 2 == 0) {
    for (int i = x ; i >= x / 2 ; i--) {
      auto it = s.find(i);
      fail(it == s.end());
      s.erase(it);
      if (i != x / 2) {
        auto it = s.find(i);
        fail(it == s.end());
        s.erase(it);
      }
    }     
    fail(s.empty() == false and *s.begin() <= x / 2);
  }
  else {
    for (int i = x ; i > x / 2 ; i--) {
      auto it = s.find(i);
      fail(it == s.end());
      s.erase(it);
      it = s.find(i);
      fail(it == s.end());
      s.erase(it);
    }
    fail(s.empty() == false and *s.begin() <= (x + 1) / 2);
  }
  cout << "Possible\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Rainy") {
    cout << "Sunny" << endl;
  } else {
    cout << "Rainy" << endl;
  }
}

Measured memory_bytes: 3628
a,b = map(int,input().split())
s = list(input())

num = [str(i) for i in range(10)]

if len(s) != a+b+1:
    print("No")
    import sys
    sys.exit()
for ss in s[:a]+s[a+1:]:
    if ss not in num:
        print("No")
        import sys
        sys.exit()

if s[a] != "-":
    print("No")
    import sys
    sys.exit()

print("Yes")

Measured memory_bytes: 3064
PROGRAM-ID.                      BOB_ALICE.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(600).
    01 cur     PIC 9(3)  VALUE 1.
    01 i       PIC 9(18).
    01 j       PIC 9(18).
    01 len     PIC 9(3).

    01 N       PIC 9(3).

    01 card1.
        03 card11 OCCURS 100 DEPENDING ON N.
            05 card    PIC 9(3).

    01 alice   PIC 9(5) VALUE 0.
    01 bob     PIC 9(5) VALUE 0.

    01 ZS      PIC Z(5)9.
    01 ans     PIC X(5).

    01 DUMMY   PIC X(1).

    01 q       PIC 9(2).
    01 r       PIC 9(1).

PROCEDURE                        DIVISION.
    ACCEPT N.

    ACCEPT INP.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO card(i)

        COMPUTE cur = j + 1

    END-PERFORM.

    SORT card11 ON DESCENDING KEY card.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        DIVIDE 2 INTO i GIVING q REMAINDER r
        IF R = 0 THEN
            ADD card(i) TO bob
        ELSE
            ADD card(i) TO alice
        END-IF
    END-PERFORM.

    SUBTRACT bob FROM alice.
    MOVE alice TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 504
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, K = map(int, readline().split())

    vec = []
    for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

    print(vec[-K])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <stdio.h>


int main(void){
                                                                                                
       
    int a[3];
   
      
    scanf("%d %d %d", &a[0], &a[1], &a[2] );


    if( a[0] == 5 && a[1] == 7 && a[2] == 5 ) printf("YES\n");

    else if( a[0] == 5 && a[1] == 5 && a[2] == 7 ) printf("YES\n");

    else if( a[0] == 7 && a[1] == 5 && a[2] == 5 ) printf("YES\n");

    else printf("NO\n");


    return 0;
                                                          
}

Measured memory_bytes: 128
from collections import deque


def BFS(G, V, start):
    dist = [-1] * V
    que = deque([start])
    dist[start] = 0

    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)

    return dist


N, X, Y = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(N-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[X-1].append(Y-1)
G[Y-1].append(X-1)

Dist = [0] * (N-1)
for i in range(N):
    D = BFS(G, N, i)
    for d in D:
        Dist[d-1] += 1

for ans in Dist[:N-2]:
    print(ans//2)
print(0)


Measured memory_bytes: 49500
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a:
    if y in a:
        print('Yes')
    else:
        print('No')
elif x in b:
    if y in b:
        print('Yes')
    else:
        print('No')
else:
    if y in c:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000100,MOD=1e9+7,inv3=(MOD+1)/3;
inline int add(register int a,register int b) {return a+=b,a>=MOD?a-MOD:a;}
inline int del(register int a,register int b) {return a-=b,a<0?a+MOD:a;}
inline int mul(register int a,register int b) {return 1LL*a*b%MOD;}
int n,ans,inv[MAXN];
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	inv[1]=1;
	for(register int i=2;i<=n;i++) inv[i]=mul(inv[MOD%i],MOD-MOD/i);
	for(register int i=1,pow3=1;i<=n;i++)
	{
		pow3=mul(pow3,inv3);
		ans=add(ans,mul(pow3,inv[n-i+1]));
	}
	ans=mul(ans,inv[n]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=100005;
int x[MAX_N];
int g[MAX_N];
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>x[i];
	}
	sort(x,x+m);
	for(int i=1;i<m;i++)g[i]=x[i]-x[i-1];
	sort(g+1,g+m);
	int ans=0;
	for(int i=1;i<=m-n;i++)ans+=g[i];
	cout<<ans<<endl;
	return 0;
}


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

int gcd(int n,int m){
  if(m==0){
    return n;
  }
  else{
    return gcd(m,n%m);
  }
}

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=gcd(a[0],a[1]);
  for(int i=2;i<n;i++){
    ans=gcd(ans,a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << A[0]/3  << endl;
}

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

using namespace std;


int main()
{
    int M, D;
    scanf("%d%d", &M, &D);

    int ans = 0;
    for (int d = 22; d <= D; ++d)
        if (d % 10 >= 2 && (d % 10) * (d / 10) <= M)
            ++ans;

    printf("%d", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int MAX_INT = 1000000;
int dp[31];
int n;
int solve(int a);
int main(){
  while(1){
    memset(dp,-1,sizeof(dp));
    cin >> n;
    if(n==0)break;
    cout << (solve(n)/10-1)/365+1 << endl;
  }
}
int solve(int a){
  if(dp[a] != -1)return dp[a];
  else{
    if(a == 0)return 1;
    else if(a < 0)return 0;
    else return dp[a] = solve(a-1)+solve(a-2)+solve(a-3);
  }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int  n = sc.nextInt();
   if(n % 2 == 0){
     System.out.println(n);
   }else{
     System.out.println(2 * n);
   }
 }

}


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

long long max(long long a, long long b, long long c){
	long long x=a;
	if(x<a)x=a;
	if(x<b)x=b;
	if(x<c)x=c;
	return x;
}
long long min(long long a,long long b,long long c){
	long long x=a;
	if(x>a)x=a;
	if(x>b)x=b;
	if(x>c)x=c;
	return x;
}
int main(void){
	long long H,W,A,B,C,temp,temp2;
	long long i;
	long long h;
	cin >> H >> W;
	long long ans = H*W;
	for(i=1;i<H;i++){
		A = i * W;
		B = ((H-i)/2)*W;
		C = H*W - A - B;
		temp = max(A,B,C);
		temp2= min(A,B,C);
		ans = min(ans,(temp-temp2));
	}
	for(i=1;i<H;i++){
		A = i * W;
		B = (H-i)*(W/2);
		C = H*W - A - B;
		temp = max(A,B,C);
		temp2= min(A,B,C);
		ans = min(ans,(temp-temp2));
	}
	swap(H,W);
	for(i=1;i<H;i++){
		A = i * W;
		B = ((H-i)/2)*W;
		C = H*W - A - B;
		temp = max(A,B,C);
		temp2= min(A,B,C);
		ans = min(ans,(temp-temp2));
	}
	for(i=1;i<H;i++){
		A = i * W;
		B = (H-i)*(W/2);
		C = H*W - A - B;
		temp = max(A,B,C);
		temp2= min(A,B,C);
		ans = min(ans,(temp-temp2));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#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)
#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 isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define int long long
#define debug(var) cout << "[" << #var << "] " << var << endl
//using ll = long long;
using ipair = pair<int,int>;

bool operator> (const pair<int,int> a, const pair<int,int> b){return a.second > b.second;};
bool operator< (const pair<int,int> a, const pair<int,int> b){return a.second < b.second;};

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    string T;
    cin >> T;
    
    rep (i, T.size()) {
        if (T[i] == '?') {
            cout << 'D';
        } else {
            cout << T[i];
        }
    }
}

Measured memory_bytes: 3748
n = int(input())
lst = [input().split() for _ in range(n)]
ans = 0
for i in range(n):
    lst[i][0] = float(lst[i][0])
    if lst[i][1] == 'BTC':
        lst[i][0] *= 380000

    ans += lst[i][0]
print(ans)



Measured memory_bytes: 3060
const v: [char; 10] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
fn main() {
    let n: usize = read();
    let mut cand: Vec<Vec<char>> = vec![vec!['a']];
    for i in 1..n {
        let mut newcand: Vec<Vec<char>> = vec![];
        for c in &mut cand {
            for j in 0..i + 1 {
                let mut next_c = c.clone();
                next_c.push(v[j]);
                newcand.push(next_c);
            }
        }
        cand = newcand;
    }
    cand.sort();
    let mut homoid: HashSet<Vec<(usize, usize)>> = HashSet::new();
    for c in cand {
        let mut candid = vec![];
        for i in 0..n {
            for j in i + 1..n {
                if c[i] == c[j] {
                    candid.push((i, j));
                }
            }
        }
        if homoid.contains(&candid) {
            continue;
        } else {
            homoid.insert(candid);
            println!("{}", c.into_iter().collect::<String>());
        }
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 413796
import math
from collections import defaultdict
def prime_factorize(n):
    prime_numbers = []
    for p in range(2, int(math.sqrt(n)+1)):
        if n % p != 0:
            continue
        while n % p == 0:
            n /= p
            prime_numbers.append(p)

    if n != 1:
        prime_numbers.append(n)
    return prime_numbers

def solve():
    N = int(input())
    MOD = 10 ** 9 + 7

    counter = defaultdict(int)
    for i in range(N,0,-1):
        primes = prime_factorize(i)
        for prime in primes:
            counter[prime] += 1

    ans = 1
    for prime, count in counter.items():
        ans *= count + 1
    
    print(ans % MOD)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 42604
// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------

use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        h: usize,
        w: usize,
        s: [Bytes; h],
    }
    let mut ans = std::cmp::max(h, w);
    let mut height = vec![1; w];
    height[w - 1] = 0;
    let mut stack: Vec<(usize, usize)> = vec![];
    for i in 1..h {
        stack.clear();
        for j in 0..w {
            if j + 1 < w {
                let mut cnt = 0;
                for (x, y) in [(!0, 0), (!0, 1), (0, 0), (0, 1)].iter() {
                    cnt += (s[i + x][j + y] == b'#') as usize;
                }
                if cnt & 1 == 0 {
                    height[j] += 1;
                } else {
                    height[j] = 1;
                }
            }
            stack.push((i + 1, j));
            let mut p = j;
            while stack.last().map_or(false, |p| p.0 > height[j]) {
                let (x, y) = stack.pop().unwrap();
                p = y;
                ans.chmax(x * (j + 1 - y));
            }
            stack.push((height[j], p));
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 10076
#include <cstdio>
#include <vector>

#define int long long
#define dotimes(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

struct union_find {
  vector<int> p, w;
  union_find(int n): p(n), w(n) {
    dotimes(x, n) {
      p[x] = x;
      w[x] = 1;
    }
  }
  int abs(int x) {
    return w[find(x)];
  }
  int find(int x) {
    while (x != p[x]) {
      int y = p[x];
      p[x] = p[y];
      x = y;
    }
    return x;
  }
  bool eqv(int x, int y) {
    int a = find(x), b = find(y);
    return a == b;
  }
  bool unite(int x, int y) {
    int a = find(x), b = find(y);
    if (a == b)
      return true;
    if (!(a < b))
      swap(a, b);
    p[b] = a;
    w[a] += w[b];
    return false;
  }
};

signed main() {
  int N = rint();
  int M = rint();
  pair<int, int> edges[M];
  dotimes(i, M) {
    edges[i].first = rint() - 1;
    edges[i].second = rint() - 1;
  }
  union_find uf(N);
  int r[M+1];
  r[M] = N * (N - 1) / 2;
  for (int i = M - 1; i >= 0; i--) {
    int x = uf.find(edges[i].first), y = uf.find(edges[i].second);
    if (x == y)
      r[i] = r[i+1];
    else {
      r[i] = r[i+1] - uf.abs(x) * uf.abs(y);
      uf.unite(x, y);
    }
  }
  dotimes(i, M)
    wint(r[i+1]);
  return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

/**
 * Created on 16/09/24.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        String result = S.substring(0, 4) + " " + S.substring(4);
        System.out.println(result);
    }
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=100010;
int n,x[Nmax];
bool alice;

int Snuke(int l){
	int res=0,j=0;
	REP(i,n){
		while(j<n&&x[j]-x[i]<l)j++;
		chmax(res,j-i);
	}
	return res;
}

pi Rng(int l){
	int q=0,p=0;
	for(int i=0;i<n;){
		int j=i;
		while(j<n&&x[j]-x[i]<l)j++;
		int w=j-i;
		if(w>=2)q+=w-2;
		else p++;
		i=j;
	}
	return pi(q,p);
}

bool Wafrelka(int l){
	if((n%2==0)^alice){
		int s=Snuke(l);
		if(alice){
			if(s>=n/2+2)return false;
			else return true;
		}else{
			if(s>=n/2+1)return false;
			else return true;
		}
	}else{
		pi r=Rng(l);
		if(alice){
			if(r.first>=r.second)return false;
			else return true;
		}else{
			if(r.first>=r.second-1)return false;
			else return true;
		}
	}
	
}

signed main(){
	n=read();
	alice=readString()=="Alice";
	REP(i,n)x[i]=read();
	int l=1,r=1000000001;
	while(r-l>1){
		int m=(r+l)/2;
		if(Wafrelka(m))l=m;
		else r=m;
	}
	cout<<l<<endl;
}


Measured memory_bytes: 4048
#include <iostream>

int main()
{
	int A, B = 0;
	char op;
	std::cin >> A >> op >> B;

	if (op == '+')
	{
		std::cout << A + B << "\n";
	}
	else if (op == '-')
	{
		std::cout << A - B << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int i =1;

      while(true){

        int x = sc.nextInt();

        if( x!= 0){
          System.out.println( "Case " + i + ": " + x );
          i++;
        }else{
          break;
        }

      }

    } 
}


Measured memory_bytes: 41076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


class UnionFind{
public:
    UnionFind(int n){
        size = n;
        parent = vector<int>(size,-1);
    }
    int getSize(){return size;}
    int getParentElement(int index){return parent[index];}
    int getGroupSize(int index){return abs(getParentElement(find(index)));}
    bool isSame(int x, int y){return find(x)==find(y);}
    void printParent(){
        for(auto v: parent) {cout << v << " ";}
        cout << endl;
    }
    int find(int x){
        int a = x;
        vector<int> children;
        while(parent[a]>=0){
            children.push_back(a);
            a = parent[a];
        }
        for(auto child: children){parent[child] = a;}
        return a;
    }
    int Union(int x, int y){
        int root_x = find(x);
        int root_y = find(y);
        if(root_x != root_y){
            if(parent[root_x]>=parent[root_y]){
                parent[root_x] += parent[root_y];
                parent[root_y] = root_x;
            }else{
                parent[root_y] += parent[root_x];
                parent[root_x] = root_y;
            }
        }
        return parent[root_x];
    }
private:
    int size;
    vector<int> parent;
};


int main(){
    int n,m,k;
    cin >> n>>m>>k;

    UnionFind uf(n);
    vector<vector<int>> edge(n);
    vector<int> ans(n, 0);
    //dbg(uf.getSize());
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.Union(a,b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    for(int i = 0; i < n; i++){
        ans[i] = uf.getGroupSize(i) - 1 - edge[i].size();
    }
    for(int i = 0; i < k; i++){
        int c, d;
        cin >> c >> d;
        c--; d--;
        if(uf.isSame(c,d)){ans[c]--; ans[d]--;}
    }

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





    return 0;

}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/09  Problem: SQUARE869120CONTEST_03 A / Link: https://atcoder.jp/contests/s8pc-3/  ----- */


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

	LL N, K; cin >> N >> K;

	VL a({4,2,0,9,7});
	LL ans = 0LL;
	FOR(i, 0, (N - 2+11) % 11) {
		for (auto it : a) {
			if (it == K) {
				ans++;
				break;
			}
		}
		for (auto &it : a) {
			it = (it + 8) % 11;
		}
	}

	ans = ans + (N-2)/11 * 5;
	cout << (ans) << "\n";

	return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;

int n, m;
vector<int> vs[N];
int memo[N];

int dp(int at) {
    int &ans = memo[at];
    if(ans != -1) return ans;
    ans = 0;
    for(int v : vs[at]) {
        int cur = 1 + dp(v);
        ans = max(ans, cur);
    }
    return ans;
}

void solve() {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        vs[u].push_back(v);
    }
    memset(memo, -1, sizeof(memo));
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans = max(ans, dp(i));
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 7424
import java.io.*;
import java.util.*;
class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		//Buffered
		int t = 1;
		// t = Integer.parseInt(reader.readLine());
		// long[] list = Arrays.stream(reader.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
		for(int u = 0;u<t;u++){
			long[] list = Arrays.stream(reader.readLine().split("")).mapToLong(Long::parseLong).toArray();
			long sum = 0;
			for(long l:list){
				sum=(sum+l)%9;
			}
			System.out.println(sum==0?"Yes":"No");
		}
	
	}
	
}
class pair implements Comparable<pair>{
		long a = 0;
		int b = 0;
		public pair(long a,int b){
			this.a = a;
			this.b = b;
		}
		@Override
		public int compareTo(pair p){
			if(this.a == p.a) return -(Integer.compare(this.b,p.b));
			else return -(Long.compare(this.a,p.a));
		}
		@Override
		public String toString(){
			return a+" "+b;
		}
	}

Measured memory_bytes: 62156
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long llong;

llong n,x;
llong a[100111];

int main()
{
    llong i;
    llong ans = 0;
    llong sum = 0;

    scanf("%lld %lld",&n,&x);

    for (i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);

        sum += a[i];
    }

    sort(a+1,a+1+n);

    if (sum < x)
    {
        ans--;
    }

    for (i=1;i<=n;i++)
    {
        if (a[i] <= x)
        {
            x -= a[i];
            ans++;
        }
        else
            break;
    }

    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,C ;
    cin >> N >> C;
    int a[C];
    int sum=0;
    for (int i=0 ; i<C ; i++){
        cin >> a[i];
        sum=sum+a[i];
    }
    int Q=sum/(N+1);
    int R=sum%(N+1);
    if(R==0){
        cout << Q << endl;
    } else {
        cout << Q+1 << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, n;
  string s, t, u;
  in3(n, s, t);
  a = 0;
  bool h;
  while(a < n + 1){
    h = true;
    b = 0;
    while(b + a < n){
      if(s[b + a] != t[b])
        h = false;
      b++;
    }
    if(h){
      out(n + a);
      memi;
      return 0;
    }
    a++;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int a[5000];
int rate[9];

int rateToIndex(int x) {
  if (x < 400) {
    return 0;
  } else if (x < 800) {
    return 1;
  } else if (x < 1200) {
    return 2;
  } else if (x < 1600) {
    return 3;
  } else if (x < 2000) {
    return 4;
  } else if (x < 2400) {
    return 5;
  } else if (x < 2800) {
    return 6;
  } else if (x < 3200) {
    return 7;
  } else {
    return 8;
  }
}

void solve() {
  for (int i=0;i<n;i++) {
    rate[min(a[i], 3200) / 400]++;
  }
  int cnt = 0;
  for (int i=0;i<8;i++) {
    cnt += (rate[i] > 0);
  }
  cout << max(1, cnt) << " " << cnt + rate[8] << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct LazySegTree{
    int n; vector<int> dat,lazy;
    //初期化
    LazySegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<int>(2*n-1,0);
        lazy=vector<int>(2*n-1,0);
    }

    void setLazy(int k, int v){
        lazy[k] = v;
        dat[k] = v;
    }

    void push(int k, int l, int r){
        if(lazy[k]!=0){
            setLazy(2*k+1,lazy[k]);
            setLazy(2*k+2,lazy[k]);
        }
        lazy[k]=0;
    }

    void fix(int k, int l, int r){
        dat[k] = dat[2*k+1]&dat[2*k+2];
    }

    int merge(int x, int y){
        return x&y;
    }

    //内部的に投げられるクエリ
    void _update(int a, int b, int x, int k, int l, int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            setLazy(k,x);
            return;
        }

        push(k,l,r);
        _update(a,b,x,2*k+1,l,(l+r)/2);
        _update(a,b,x,2*k+2,(l+r)/2,r);

        fix(k,l,r);
    }
    //[a,b)をxに更新
    void update(int a, int b, int x){
        return _update(a,b,x,0,0,n);
    }

    //内部的に投げられるクエリ
    int _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return 1;
        if(a<=l && r<=b) return dat[k];

        push(k,l,r);
        int vl=_query(a,b,2*k+1,l,(l+r)/2);
        int vr=_query(a,b,2*k+2,(l+r)/2,r);
        return merge(vl,vr);
    }
    //[a,b)
    int query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

const int N = 200000;
vector<int> C[N],Q[N];

int main(){
    int n,m,q;
    scanf(" %d %d %d", &n, &m, &q);

    vector<int> d(m),a(m),b(m);
    rep(i,m) scanf(" %d %d %d", &d[i], &a[i], &b[i]);

    vector<int> e(q),s(q),t(q);
    rep(i,q) scanf(" %d %d %d", &e[i], &s[i], &t[i]);

    vector<int> v;
    rep(i,m) v.pb(d[i]);
    rep(i,q) v.pb(e[i]);
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    int V = v.size();

    rep(i,m){
        int idx = lower_bound(all(v), d[i])-v.begin();
        C[idx].pb(i);
    }
    rep(i,q){
        int idx = lower_bound(all(v), e[i])-v.begin();
        Q[idx].pb(i);
    }

    LazySegTree st(n+1);
    vector<bool> ans(q);
    rep(i,V){
        for(int &ID:Q[i]) ans[ID] = st.query(s[ID], t[ID]);
        for(int &ID:C[i]) st.update(a[ID], b[ID], 1);
    }
    rep(i,q) printf("%s\n", (ans[i]?"Yes":"No"));
    return 0;
}



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

int main(){
  int n; cin>>n;
  vector<long long> a(n);
  long long x=0LL;
  for(int i=0; i<n; ++i){
    cin>>a[i];
    if(i%2==0)x+=a[i];
    else x-=a[i];
  }
  cout<<x<<" ";
  x/=2;
  for(int i=0; i<n-1; ++i){
    x=a[i]-x;
    cout<<x*2<<" ";
  }
  cout<<endl;
  
}


Measured memory_bytes: 2048
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion

	
int main(void)
{
	int n,i;
	int j[4] = { 0,0,0,0 };
	char c[4];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", c);
		switch (c[0]) {
		case 'A':j[0]++; break;
		case 'W':j[1]++; break;
		case 'T':j[2]++; break;
		case 'R':j[3]++; break;
		}
	}

	printf("AC x %d\n", j[0]);
	printf("WA x %d\n", j[1]);
	printf("TLE x %d\n", j[2]);
	printf("RE x %d\n", j[3]);
		
	return 0;

}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll k, a, b;
    cin >> k >> a >> b;

    ll res = 1;
    if(a+2 < b){
        if(k >=  a-1){
            res += a-1;
            k -= a-1;
            if(k%2 == 1) res++,k--;
            res += (b-a)*(k/2);
        }else{
            res += k;
        }
    }else{
        res += k;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq & x)
{
    x = 0;
    rg int f = 1;
    rg char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    x *= f;
}
template <typename qaq> inline void print(qaq x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}
LL x,y,ans,temp;
inline void work1()//都大于0 
{
	if (y == 0) --ans;
	if (x > y)
	{
		ans += x - y + 2;//首先让x变为负,才可以实现+1操作让其绝对值变小;绝对值相等后,让x为正 
	}
	else ans += y - x;//否则直接相加即可 
}
inline void work2()//x大于等于0 y小于0 
{
	ans += abs(x + y) + 1;//若x < abs(y),先让x + 1至x = abs(y)再为负,否则让x为负再疯狂+ 1让x = y 
}
inline void work3()//x小于0 y大于等于0 
{
	if (y == 0) --ans;
	ans += abs(x + y) + 1;//若x > abs(y),先让x + 1至x = abs(y)再为正,否则让x为正再疯狂+ 1让x = y
}
inline void work4()//x小于0 y小于0 
{
	if (x > y)
	{
		ans += x - y + 2;//首先让x变为正,才可以实现+1操作让其绝对值变大;绝对值相等后,让x为负 
	}
	else ans += y - x;//否则直接相加即可 
}
int main()
{
	read(x),read(y);
	if (x == y) ans = 0;
	else if (x >= 0 && y >= 0) work1();
	else if (x >= 0 && y < 0) work2();
	else if (x < 0 && y >= 0) work3();
	else if (x < 0 && y < 0) work4();
	print(ans); 
}//noHash!

Measured memory_bytes: 256
/**********************************************
*   UPDATE CONDITION & OVERFLOW CONDITION     *
**********************************************/

#include<bits/stdc++.h>
using namespace std;

#define pi 3.1415926535
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t; while(t--)
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const long long int inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    int x, n;
    cin >> x >> n;
    vi a(n);
    get(a,n);
    bool has[1010] = {0};
    int ans = -1, diff = 10000;
    f(i,0,n)
    {
        has[a[i]] = true;
    }

    f(i,-105,105)
    {
        if(abs(i-x) < diff && !has[i])
        {
            ans = i;
            diff  = abs(i-x);
        }
    }
    cout << ans;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string.h>
int main(void) {
	char S[6] = {};

	std::cin >> S;

	if (strstr(S, "AC")) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static bool solve(string s)
        {
            for(int i = 0; i < 3; i++)
            {
                if (s[i] == s[i+1]) return false;
            }
            return true;
        }
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            bool ans = solve(s);

            if (ans)
            {
                Console.WriteLine("Good");
            }
            else
            {
                Console.WriteLine("Bad");
            }
        }


    }
}

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

using namespace std;

#define lint long long

const lint mod = 1E9 + 7;


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

    vector<int> A(N), B(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        B[i] = A[i];
    }
    
    sort(A.begin(), A.end());


    for(int i = 0; i < N; ++i){
        if(B[i] == A[N - 1]){
            cout << A[N - 2] << endl;
        } else {
            cout << A[N - 1] << endl;
        }
    }

}

Measured memory_bytes: 3200
use std::io::Read;

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

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut values: Vec<usize> = Vec::with_capacity(n);
    for _i in 0..n {
        values.push(iterator.next().unwrap().parse().unwrap());
    }

    values.sort_by(|a,b| b.cmp(a));
    let mut ans: f64 = values.pop().unwrap() as f64;
    for _i in 0..(n-1) {
        ans = (ans + values.pop().unwrap() as f64) / 2.0;
    }

    return format!("{:.10}", ans);
}

fn make(n: usize) -> Vec<Vec<usize>> {
    let mut original = Vec::new();
    for i in 1..(n + 1) {
        original.push(i)
    }

    let mut result = Vec::new();
    _make(original, Vec::new(), &mut result);
    return result;
}

fn _make(candidate: Vec<usize>, perm: Vec<usize>, result: &mut Vec<Vec<usize>>) {
    if candidate.is_empty() {
        result.push(perm);
        return;
    }

    for i in 0..candidate.len() {
        let mut c = candidate.clone();
        let mut p = perm.clone();
        p.push(c.remove(i));
        _make(c, p, result);
    }
}

#[test]
fn test() {
    println!(
        "{}",
        solve(
            r"2
3 4"
        )
    );
    println!(
        "{}",
        solve(
            r"3
500 300 200"
        )
    );
    println!(
        "{}",
        solve(
            r"5
138 138 138 138 138"
        )
    );
}


Measured memory_bytes: 4352
using System;

class Program
{
	static bool[] isNotPrime = new bool[10001]; 
	public static int Main()
	{
		//Scanner cin = new Scanner();
		isNotPrime[0] = isNotPrime[1] = true;
		for (int i = 2; i * i <= 10000; i += 2)
		{
			if (!isNotPrime[i])
			{
				for (int j = i * i; j <= 10000; j += i)
				{
					isNotPrime[j] = true;
					if (i != 2)
					{
						j += i;
					}
				}
				if (i == 2)
				{
					i--;
				}
			}
		}
		string input;
		while (!string.IsNullOrEmpty(input = Console.ReadLine()))
		{
			int n = int.Parse(input);
			int P = 0;
			for (int i = 1; i <= n; i++)
			{
				if (!isNotPrime[i] && !isNotPrime[n - i + 1])
				{
					P++;
				}
			}
			Console.WriteLine(P);
		}
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5664
// Author: Shusuke Ueda
// AtCoder Beginner Contest 126 - Problem E

#include <iostream>
#include <vector>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<bool> visited(n, false);
    std::vector<std::vector<int>> to(n, std::vector<int>(0));
    for (int i = 0; i < m; i++) {
        int x, y, z;
        std::cin >> x >> y >> z;
        x--;
        y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    auto dfs = [&](auto&& dfs_, int pos) -> void {
        visited[pos] = true;
        for (int nex: to[pos]) {
            if (visited[nex] == false) {
                dfs_(dfs_, nex);
            }
        }
    };
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (visited[i] == false) {
            ans++;
            dfs(dfs, i);
        }
    }

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

Measured memory_bytes: 7808
import itertools
n = int(input())
s = [i for i in input()]
cnt_s, cnt_d = [0]*(n+1), [0]*(n+1)
for i in range(n):
    if s[i] == "#":
        cnt_s[i+1] = 1
    else:
        cnt_d[i+1] = 1
cnt_s, cnt_d = list(itertools.accumulate(cnt_s)), list(itertools.accumulate(cnt_d))
ans = 10**6
cnt_d_l = cnt_d[-1]
for i in range(n+1):
    ans = min(ans, cnt_s[i] - cnt_s[0] + (cnt_d_l - cnt_d[i]))
print(ans)

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

int main()
{
	int a[9];
	for (auto &e : a) std::cin >> e;
	int n;
	std::cin >> n;
	int b;
	for (int i = 0; i < n; i++) {
		std::cin >> b;
		auto p = std::find(a, a + 9, b);
		if (p != a + 9) *p = 0;
	}
	
	for (int i = 0; i < 9; i += 3) {
		if ((a[i] | a[i + 1] | a[i + 2]) == 0) {
			goto BINGO;
		}
	}
	for (int i = 0; i < 3; i++) {
		if ((a[i] | a[i + 3] | a[i + 6]) == 0) {
			goto BINGO;
		}
	}
	if ((a[0] | a[4] | a[8]) == 0) {
		goto BINGO;
	}
	if ((a[2] | a[4] | a[6]) == 0) {
		goto BINGO;
	}
	std::cout << "No" << std::endl;
	return 0;
	
BINGO:
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 3140
D,G = gets.split.map(&:to_i)
P,C = Array.new(D){gets.split.map(&:to_i)}.transpose

min = 999999999

# with complete bonus
A = D.times.map{|i| P[i] * 100 * (i+1) + C[i]}

count = 99999999
(2**D).times do |i|
    bit = D.times.map{|j|i[j]}
    point = A.zip(bit).inject(0){|a,b|a+=b[0]*b[1]}
    num = P.zip(bit).inject(0){|a,b|a+=b[0]*b[1]}
    if point >= G
        count = num if count > num
    else
        m = D - 1 - bit.reverse.find_index(&:zero?)
        if m
            diff = G - point
            add = (diff.to_f/100/(m+1)).ceil
            if add < P[m]
                num += add
                count = num if count > num
            end
        end
    end
end

puts count

Measured memory_bytes: 1916