akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;

int main(){
  int n, a, b;
  cin>>n>>a>>b;
  cout<<min(n*a, b);
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define P pair<int, int>
struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int n, k;
llong a[1000];


int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	llong rui[1001] = {};
	for(int i = 0; i < n; i++){
		rui[i+1] = rui[i] + a[i];
	}
	vector<llong> lst;
	for(int i = 0; i <= n-1; i++){
		for(int j = i+1; j <= n; j++){
			lst.pb(rui[j] - rui[i]);
		}
	}
	sort(lst.begin(), lst.end(), greater<llong>());

	vector<llong> check;
	llong better = 1ll<<40;
	while(better){
		int index = check.size();
		for(int i = index; i < lst.size(); i++){
			if(lst[i] >= better)
				check.pb(lst[i]);
			else
				break;
		}
		if(check.size() >= k)
			break;

		better >>= 1;
	}

	llong ans = 0;
	vector<llong> ok = check, before = check;
	int index = 40;
	while(index >= 0){
		ans <<= 1;
		for(int i = ok.size()-1; i >= 0; i--){
			if( !((ok[i]>>index) & 1) )
				ok.erase(ok.begin()+i);
		}
		if(ok.size() >= k){
			ans += 1;
			before = ok;
		}else{
			ok = before;
		}
		index--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7020
import sys
input = sys.stdin.readline

n = int(input())

A = [0] * (10**6 + 5)
for i in range(2, int(n**0.5) + 1):
    while n % i == 0:
        n //= i
        A[i] += 1

if n != 1:
    A.append(1)
# print(A[:5])

ans = 0

def a(x):
    l = 0
    r = 10**6 + 5
    m = (l+r)//2
    while r-l > 1:
        if m*(m+1)//2 > x:
            r = m
        else:
            l = m
        m = (l+r)//2
    return l
A.sort(reverse=True)
for i in range(len(A)):
    if A[i] == 0:
        break
    ans += a(A[i])
print(ans)

Measured memory_bytes: 79168
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    set<int> s;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        if(s.find(a) == s.end())
            s.insert(a);
        else
            s.erase(a);
    }
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 4864
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

LL n, k;
const LL MOD = 1000000007;
LL combi(LL N_, LL C_) {
	const int NUM_ = 400001;
	static LL fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%MOD, factr[i] = factr[i - 1] * inv[i] % MOD;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % MOD*factr[N_ - C_] % MOD;
}
//K個のものから重複を許してN個選ぶ時の組み合わせ
LL hcomb(int P_, int Q_) { return (P_ == 0 && Q_ == 0) ? 1 : combi(P_ + Q_ - 1, Q_); }

LL modpow(LL a, LL n = MOD - 2) {
	LL r = 1;
	while (n) r = r*((n % 2) ? a : 1) % MOD, a = a*a%MOD, n >>= 1;
	return r;
}

int main() {
	cin >> n >> k;
	cout << (n > k ? 0 : 1) << endl;
}


Measured memory_bytes: 3068
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[cfg(debug_assertions)]
macro_rules! debug {
      ($($a:expr),*) => {
          println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}

use std::collections::VecDeque;
fn main() {
  input!{
    h: usize, w:usize, n:usize,
    sy: usize, sx: usize,
    s: chars,
    t: chars
  }
  let cc = ['L', 'R', 'U', 'D'];
  let tc = ['R', 'L', 'D', 'U'];
  let mut win = false;
  for c in 0..4 {
    let mut pos = 0i64;
    let m = cc[c];
    let y = tc[c];
    for i in 0..n {
      if s[i] == m {
        pos += 1;
      }
      //debug!(m, y, pos);
      let sy = sy as i64 - 1;
      let sx = sx as i64 - 1;

      let h = h as i64;
      let w = w as i64;

      if m == 'L' {
        if sx - pos < 0 {win = true;}
      }
      if m == 'R' {
        if sx + pos >= w {win = true;}
      }
      if m == 'U' {
        if sy - pos < 0 {win = true;}
      }
      if m == 'D' {
        if sy + pos >= h {win = true;}
      }
      if t[i] == y {
        pos -= 1;
        if y == 'L' && sx + pos < 0 {
          pos += 1;
        }
        if y == 'R' && sx - pos >= w {
          pos += 1;
        }
        if y == 'U' && sy + pos < 0 {
          pos += 1;
        }
        if y == 'D' && sy - pos >= h {
          pos += 1;
        }
      }
    }
  }
  if win {println!("NO")}
  else {println!("YES")}
}

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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {

    int r, c;
    cin >> r >> c;
    int num[ r + 1 ][ c + 1 ]={};
    rep( i, r ) {
        int sum = 0;
        rep( j, c ) {
            int t;
            cin >> num[ i ][ j ];
            cout << num[ i ][ j ] << " ";
            num[ i ][ c ] += num[ i ][ j ];
        }
        cout << num[ i ][ c ] << endl;
    }

    rep( i, c + 1 ) {
        rep( j, r ) num[ r ][ i ] += num[ j ][ i ];
        if( i < c )
            cout << num[ r ][ i ] << " ";
        else
            cout << num[ r ][ i ] << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn main() {
    input! {
        n: usize,
        heights: [i32; n],
    }
    let mut minimum_costs = vec![0; n];
    minimum_costs[0] = 0;
    minimum_costs[1] = (heights[1] - heights[0]).abs();
    for i in 2..=(n - 1) {
        minimum_costs[i] = i32::min(
            minimum_costs[i - 1] + (heights[i] - heights[i - 1]).abs(),
            minimum_costs[i - 2] + (heights[i] - heights[i - 2]).abs(),
        );
    }
    println!("{}", minimum_costs[n - 1])
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;

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

    ll biscuits;
    if (b - a < 2){
        biscuits = k + 1;
    }
    else{
        biscuits =  a + (b - a) * ((k - a + 1) / 2) + (k - a + 1) % 2;
    }
    cout << biscuits << endl;
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<int>a(3); for(auto&i:a)cin>>i;
	cout<<*max_element(a.begin(),a.end())-*min_element(a.begin(),a.end())<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

const int maxn = 1e4 + 5;
int r, c, n;
int cnt[maxn];
int col[105][105];

void dfs(int x, int y, int u, int op){
  if(x == r + 1) return ;
  col[x][y] = u;
  if(-- cnt[u] == 0) u ++;
  if(op == 0){
	if(y == c) dfs(x + 1, c, u, 1);
	else dfs(x, y + 1, u, 0);
  }
  else{
	if(y == 1) dfs(x + 1, 1, u, 0);
	else dfs(x, y - 1, u, 1);
  }
}

int main(){
  rd(r), rd(c), rd(n);
  rep(i, 1, n) rd(cnt[i]);
  dfs(1, 1, 1, 0);
  rep(i, 1, r){
	rep(j, 1, c) printf("%d ", col[i][j]);
	puts("");
  }
  return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()

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

    ll n,m,k[31],a[31][31],num[31],ans=0;
    Cin2(n,m);
    rep(i,n){
        Cin(k[i]);
        rep(j,k[i]){
            Cin(a[i][j]);
        }
    }
    rep(i,31) num[i]=0;
    rep(i,n){
        rep(j,k[i]){
            num[a[i][j]]++;
        }
    }
    rep(i,m+1){
        if(num[i]==n) ans++;
    }
    Cout(ans);
    return 0;
}

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

int main(){
	int mn=1000100,n,i,j,sum=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>j;
		if(j%10!=0)mn=min(mn,j);
		sum+=j;
	}
	if(sum%10!=0){
		cout<<sum;
	}else if((sum-mn)%10!=0){
		cout<<sum-mn;
	}else{
		cout<<0;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9+7)
#define MAX_V (200)
#define MAX_E (10000)
#define MAX_R (1000)
#define MAX_C (1000)

struct Postman { int pos; int ship; int cost; };

int V, E, R;
int DL[MAX_V][MAX_V], DS[MAX_V][MAX_V], DP[MAX_R][MAX_V], PATH[MAX_R];

void warshall_floyd(int d[][MAX_V]) {
  for (size_t w = 0; w < V; w++)
    for (size_t u = 0; u < V; u++)
      for (size_t v = 0; v < V; v++) d[u][v] = min(d[u][v], d[u][w] + d[w][v]);
}

void solve() {
  warshall_floyd(DL);
  warshall_floyd(DS);

  for (size_t i = 0; i < R; i++)
    for (size_t v = 0; v < V; v++) DP[i][v] = INF;
  DP[0][PATH[0]] = 0;

  for (size_t i = 1; i < R; i++) {
    int u = PATH[i - 1], v = PATH[i];
    for (int w = 0; w < V; w++) {
      for (int x = 0; x < V; x++) {
//        printf("DP[%d][%d]+DL[%d][%d]+DS[%d][%d]+DL[%d][%d] = %d\n",i-1,w,u,w,w,x,x,v,d);
        int d = DP[i-1][w];
        d += (w == x)? DL[u][v]: DL[u][w] + DS[w][x] + DL[x][v];
        DP[i][x] = (0 <= d)? min(DP[i][x], d): DP[i][x];
      }
    }
  }

  int ans = INF;
  for (size_t v = 0; v < V; v++) {
    ans = min(ans, DP[R-1][v]);
  }
  printf("%d\n", ans);
}

int main() {
  while (true) {
    scanf("%d %d", &V, &E);
    if (V == 0) break;
    for (size_t v = 0; v < V; v++)
      for (size_t u = 0; u < V; u++) DL[v][u] = DS[v][u] = (u == v)? 0: INF;

    for (size_t i = 0; i < E; i++) {
      int v, u, cost; char c;
      scanf("%d %d %d %c\n", &v, &u, &cost, &c);
      v--; u--;
      if (c == 'L') {
        DL[u][v] = DL[v][u] = min(DL[u][v], cost);
      } else {
        DS[u][v] = DS[v][u] = min(DS[u][v], cost);
      }
    }

    scanf("%d", &R);
    for (size_t i = 0; i < R; i++) {
      scanf("%d", &PATH[i]);
      PATH[i]--;
    }

    solve();
  }

  return 0;
}

Measured memory_bytes: 4244
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int max = a+b;
    if(max<a-b)max = a-b;   
    if(max<a*b)max = a*b;
    System.out.println(max);
  } 
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/
ll fact[400005];
ll inv(ll val)
{
  return power(val,hell-2,hell);
}
ll ncr(ll n,ll r)
{
  return ((fact[n]*inv(fact[r]))%hell*inv(fact[n-r])%hell)%hell;
}

void solve()
{
  ll n,i;
  string s;
  map<string,ll> m;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>s;
    m[s]++;
  }
  ll curr=0;
  for(auto val : m)
  {
    curr = max(curr,val.second);
  }
  vector<string> v;
  for(auto val : m)
    if(val.second==curr)
      v.pb(val.first);
  sort(all(v));
  for(auto val : v)
    cout<<val<<endl;  
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 26868
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct DAta{
  char s[21];
  int b, a;
}d[50];

int cmp(const void *a,const void *b){
  struct DAta f,e;
  f=*(struct DAta *)a;
  e=*(struct DAta *)b;
  if(f.b*e.a-f.a*e.b==0)return strcmp(f.s,e.s);
    return f.b*e.a-f.a*e.b;
}


int main(void){
  int n,i,j;
  int p,s,m,a,b,c,h,e,f;
  
  while(scanf("%d",&n),n){
  for(i=0;i<n;i++){
    scanf("%s%d%d%d%d%d%d%d%d%d",d[i].s,&p,&a,&b,&c,&h,&e,&f,&s,&m);
    d[i].a=(f*m*s-p);
d[i].b=(a+b+c+(h+e)*m);
  }
  qsort(d,n,sizeof(struct DAta),cmp);
  for(i=0;i<n;i++){
    printf("%s\n",d[i].s);
  }
  puts("#");
  }
  return 0;}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;

int main() {
	vector<complex<double> >v;
	double inx, iny;
	char c;

	complex<double> input(0, 0);
	//cout << input << endl;
	while (cin >> inx >> c >> iny) {
		complex<double> g(inx, iny);
		v.push_back(g);
	}
	double s = 0.0;
	for (int i = 1; i < v.size() - 1; i++) {
		double a = abs(v[0] - v[i]);
		double b = abs(v[0] - v[i + 1]);
		double c = abs(v[i] - v[i + 1]);
		double z = (a + b + c) / 2;
		s += sqrt(z*(z - a)*(z - b)*(z - c));
	}
	printf("%.6f\n", s);
	return 0;
}

Measured memory_bytes: 3204
import java.util.Scanner;
 
class Main{
  public static void main(String [] args){
    Scanner scan = new Scanner(System.in);
    while(scan.hasNext()){
      int x = 0;
      int y = 0;
      x = Integer.parseInt(scan.next());
      y = Integer.parseInt(scan.next());
      if(x == 0 && y ==0){break;
      }
      if(x < y){
        System.out.println(x + " " + y);
      }else{System.out.println(y + " " + x);
      }
    }
  }
}

Measured memory_bytes: 25440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,k;cin>>n>>k;
    ll sum =0;
    rep(i,n){
        int tmp;cin>>tmp;
        sum+=min(2*tmp, 2*abs(k-tmp));
    }
    co(sum);
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
ll N, M;
llvec A;

bool chk(ll m){
  ll cnt = 0;
  rep(i, N){
    ll a = A[N-i-1];
    ll tmp = (ll)( A.end() - lower_bound(ALL(A), m-a));
    cnt += tmp;
    if(cnt>M or tmp==0){break;}
  }
  return (cnt<=M);
}

/**************************************
 ** A main function starts from here  **
 ***************************************/
int main(){
  cin >> N >> M;
  A=llvec(N);
  ll mm = -1;
  rep(i, N){
    cin >> A[i];
    mm = max(A[i], mm);
  }
  sort(ALL(A));

  llvec S(N, 0);
  S[0]=A[0];
  rep(i, N-1){
    S[i+1] = S[i] + A[i+1];
  }
  
  ll l=-1,r=2*mm+1;
  while(r-l>1){
    ll m=(r+l)/2;
    if(chk(m))r=m;
    else l=m;
  }
  
  ll cnt = 0;
  ll cum = 0;
  rep(i, N){
    ll a = A[N-1-i];
    auto iter = lower_bound(ALL(A),r-a);
    ll tmp = (ll)(A.end()-iter);
    ll tmp2 = (ll)(iter-A.begin());
    if(tmp==0)break;
    cnt += tmp;
    cum += a*tmp + S[N-1];
    if(tmp2-1>=0)cum -= S[tmp2-1];
    
    
    //if(cnt==M)break;
  }
  cout << cum + l * (M-cnt);
  //cout << cum;
  return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int s = in.nextInt();
            int w = in.nextInt();
            out.println(w >= s ? "unsafe" : "safe");
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 33992
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 100000007
#define INF 1e9
/****************************/
int main()
{
	bool ha=true;
	int n;
	cin>>n;
	rep(i,n)
	{
		int a;
		cin>>a;
		if(a%2==0)
		{
			if(a%3!=0&&a%5!=0)
			{
				ha=false;
				break;
			}
		}
	}
	if(ha)
	{
		cout<<"APPROVED";
	}
	else
	{
		cout<<"DENIED";
	 } 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
# まずX_1を求める
x_1 = s
for i in range(1,n,2):
    x_1 -= 2*a[i]
ans = [x_1]
for i in range(1, n):
    ans.append(2*a[i-1]-ans[i-1])
print(" ".join(list(map(str, ans))))

Measured memory_bytes: 19092
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

llong Choose2(llong N) {
   return N*(N-1)/2;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;
   VI A(N);
   REP(i, N)
      cin >> A[i];

   VI freq(N+1);
   for (int x : A)
      ++freq[x];

   llong ans = 0;
   FOR(n, 1, N)
      ans += Choose2(freq[n]);

   REP(k, N) {
      int x = A[k];

      ans -= Choose2(freq[x]);
      --freq[x];
      ans += Choose2(freq[x]);

      cout << ans << '\n';

      ans -= Choose2(freq[x]);
      ++freq[x];
      ans += Choose2(freq[x]);
   }

   return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<cstring>
 
constexpr int MAX = 1000;
 
int dp[MAX][MAX + 1];
int W, n;
int v[MAX], w[MAX];
 
int main() {
    int cnt = 0;
    while (1) {
        std::cin >> W;
        if (W == 0)
            break;
        ++cnt;
        std::cin >> n;
        char ch;
        for (int i = 0; i < n; ++i)
            std::cin >> v[i] >> ch >> w[i];
        std::memset(dp, 0, sizeof(dp));
        dp[0][w[0]] = v[0];
        for (int i = 1; i < n; ++i) {
            for (int j = 0; j <= W; ++j) {
                dp[i][j] = dp[i - 1][j];
                if (j >= w[i])
                    dp[i][j] = std::max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
        int ans = 0, maxv;
        for (int i = W; i >= 0; --i) {
            if (ans <= dp[n - 1][i]) {
                ans = dp[n - 1][i];
                maxv = i;
            }
        }
        std::cout << "Case " << cnt << ':' << std::endl
            << ans << std::endl << maxv << std::endl;
    }
    return 0;
}

Measured memory_bytes: 7004
#include<stdio.h>
int main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if (a > b) {
    tmp=a;
    a=b;
    b=tmp;
  }
  if (a > c) {
    tmp=a;
    a=c;
    c=tmp;
  }
  if (b > c) {
    tmp=b;
    b=c;
    c=tmp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <limits.h>

#define SIZE 500000

void merge(int, int, int);
void mergesort(int, int);

int count = 0;
int a[SIZE];

int main()
{
  int n, i, left, right;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%d",&a[i]);
    }
  
  left = 0;
  right = n;

  mergesort(left, right);

  for(i = 0; i < n-1; i++)
    {
      printf("%d ",a[i]);
    }

  printf("%d\n",a[n-1]);

  printf("%d\n",count);

  return 0;
}

void merge(int left, int mid, int right)
{
  int i, j, k, n1, n2, L[SIZE/2+1], R[SIZE/2+1];

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++)
    {
      L[i] = a[left + i];
    }

  for(i = 0; i < n2; i++)
    {
      R[i] = a[mid + i];
    }

  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  i = 0;
  j = 0;

  for(k = left; k < right; k++)
    {
      if(L[i] <= R[j])
	{
	  a[k] = L[i];
	  i++;
	}
      else
	{
	  a[k] = R[j];
	  j++;
	}
      count++;
    }
}

void mergesort(int left, int right)
{
  int mid;
  
  if(left+1 < right)
    {
      mid = (left + right)/2;
      mergesort(left, mid);
      mergesort(mid, right);
      merge(left, mid, right);
    }
}



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

int main() {
    int H, W;

    while(1) {
        cin >> H >> W;

        if ((H == 0) && (W == 0)) {
            break;
        }

        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  ll r;
  IN(r);
  OUT(r*r);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, ans2=0;

	cin>>n;

	vi a(n);

	vvi b(29, vi(n));

	rep(i, n) cin>>a[i];

	rep(i, n){
		int tempb;
		cin>>tempb;
		rep(j, 29) b[j][i]=tempb%(2<<j);
	}

	rep(j, 29){
		sort(all(b[j]));
		int ans=0;
		rep(i, n){
			int tempa=a[i]%(2<<j);
			vi::iterator r1, r2, r3, r4;
			r1=lower_bound(all(b[j]), (1<<j)-tempa);
			r2=upper_bound(all(b[j]), (2<<j)-tempa-1);
			r3=lower_bound(all(b[j]), (3<<j)-tempa);
			r4=upper_bound(all(b[j]), (4<<j)-tempa-1);
			ans+=(int)(r2-r1)+(int)(r4-r3);
		}
		if(ans%2) ans2+=(1<<j);
	}
	cout<<ans2<<endl;
}

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

int main(){
    int n;
    vector<double> v;
    cin >> n;
    v.resize(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    double mmax;
    /*
    for(int i=0; i<n; i++){
        cout << v[i] << endl;
    }
    */
    for(int i=1; i<n; i++){
        // cout << "v[i-1]: " << v[i-1] << endl;
        mmax = (v[i-1] + v[i]) / 2.0;
        v[i] = mmax;
    }

    /*
    for(int i=0; i<n; i++){
        cout << v[i] << endl;
    }
    */
    cout << mmax << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
set<int>sett;
int n,k;
int a[200005];
int x[200005]; 
int ans=0;
int flag;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i==0)x[0]=0;
		else{
			if(a[i]>a[i-1])x[i]=x[i-1]+1;
			else x[i]=0;
		}
		if(x[i]>=k-1)flag=1;
	}
	for(int i=0;i<k;i++)sett.insert(a[i]);
	if(x[k-1]<k-1)ans++;
	for(int i=k;i<n;i++){
		sett.insert(a[i]);
		if((a[i]!=*sett.rbegin()||a[i-k]!=*sett.begin())&&x[i]<k-1)ans++;
		sett.erase(a[i-k]); 
	}
	cout<<(ans+flag);
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e14;

int a[102];
int dp[N];
int n;

int solve(int k){
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j] && dp[i-a[j]]==2)dp[i]=1;
        }
        if(!dp[i])dp[i]=2;
    }
    return dp[k];
}

int main() {
    fastio

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

    if(solve(k)==1){
        cout<<"First\n";
    }
    else cout<<"Second\n";
 //  for(int i=0;i<=k;i++)cout<<dp[i]<<" ";
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	cout << (t/ a) * b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int m, n, i, j;
	int a[100][100], b[100];
	long c[100] = { 0 };

	scanf("%d%d", &m, &n);

	for (i = 0;i < m;i++)
	{
		for (j = 0;j < n;j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0;i < n;i++)
	{
		scanf("%d", &b[i]);
	}
	for (i = 0;i < m;i++)
	{
		for (j = 0;j < n;j++)
		{
			c[i] += a[i][j] * b[j];
		}
	}
	for (i = 0;i < m;i++)
	{
		printf("%d\n", c[i]);
	}
	return 0;
}


Measured memory_bytes: 2104
D, G = map(int, input().split())
P = []
C = []
ans = 10 ** 9
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

for i in range(2 ** D):
    a = 0
    b = 0
    for j in range(D):
        if (i >> j) & 1 :
            a += 100 * P[j] * (j + 1) + C[j]
            b += P[j]
    for k in range(D - 1, -1, -1):
        if (i >> k) & 1:
            continue
        if a >= G:
            break
        for l in range(P[k] + 1):
            a += 100 * (k + 1)
            b += 1
            if a >= G:
                break
    ans = min(ans, b)
print(ans)

Measured memory_bytes: 3064
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        char[][] T = new char[8][8];
        Point[] Q = new Point[8];
        int[] cols = new int[8];
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < 8; i++) {
            cols[i] = i;
            Arrays.fill(T[i], '.');
        }
        for(int i = 0; i < k; i++) T[sc.nextInt()][sc.nextInt()] = 'Q';
        label:
        do {
            int t = 0;
            for(int i = 0; i < 8; i++) if(T[i][cols[i]] == 'Q') t++;
            if(t != k) continue label;
            for(int i = 0; i < 8; i++) Q[i] = new Point(cols[i], i);
            for(int i = 0; i < 7; i++) {
                for(int j = i+1; j < 8; j++) {
                    if(Q[i].x == Q[j].x || Q[i].y == Q[j].y ||
                       Math.abs(Q[i].x - Q[j].x) == Math.abs(Q[i].y - Q[j].y)) {
                        continue label;
                    }
                }
            }
            for(Point q : Q) T[q.y][q.x] = 'Q';
            for(char[] r : T) System.out.println(String.valueOf(r));
            break;
        } while(nextPermutation(cols));
    }
    public static boolean nextPermutation(int[] array) {
        int num = array.length;
        for(int i = num - 2; i >= 0; i--) {
            if(array[i] < array[i + 1]) {
                int j = num;
                do {
                    j--;
                } while(array[i] > array[j]);
                swap(array, i , j);
                Arrays.sort(array, i + 1, num);

                return true;
            }
            if(i == 0) {
                reverse(array);
            }
        }
        return false;
    }
    public static void swap(int[] array, int a, int b) {
        int tmp = array[a];
        array[a] = array[b];
        array[b] = tmp;
    }
    public static void reverse(int[] array) {
        int num = array.length;
        for(int i = 0; i < num / 2; i++) {
            swap(array, i, num - i - 1);
        }
    }
    public static void test(int[] arr) {
        swap(arr, 1, 3);
        reverse(arr);
    }
}



Measured memory_bytes: 28380
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e5 + 100;



signed main() {
	speed;
	string s;
	cin >> s;
	vector<int> cnt(1e6 + 10);
	int ans = 0;
	for (int i = 0; i < s.size(); ++i) {
		int x = s[i] - '0';
		if (x < 5) {
			cnt[s.size() - i - 1] += x;
		}
		else {
			cnt[s.size() - i - 1] += x - 10;
			cnt[s.size() - i]++;
		}
	}
	bool was = true;
	while (was) {
		was = false;
		for (int i = 0; i < s.size() + 10; ++i) {
			assert(cnt[i] > -10);
			while (cnt[i] >= 6 || (cnt[i] == 5 && cnt[i + 1] < 0)) {
				cnt[i + 1]++;
				cnt[i] -= 10;
				was = true;
			}
			while (cnt[i] < -5 || (cnt[i] == -5 && cnt[i + 1] > 0)) {
				cnt[i] += 10;
				cnt[i + 1]--;
				was = true;
			}
		}
	}
	for (int i = 0; i < s.size() + 10; ++i) {
		//cout << cnt[i] << ' ';
		ans += abs(cnt[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5276
import java.util.Scanner;

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

		if (s.contains("a") && s.contains("b") && s.contains("c")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache
import bisect

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N = Scanner.int()
    A = Scanner.map_int()
    B = Scanner.map_int()
    C = Scanner.map_int()
    A.sort()
    B.sort()
    C.sort()
    ans = 0
    for i in range(N):
        n,m = 0,0
        n = bisect.bisect_left(A,B[i])
        m = N - bisect.bisect_right(C,B[i])
        ans += n * m
    print(ans)
    return

if __name__ == "__main__":
    main()


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

int main()
{
    int sz[3],i,s,max;
    scanf("%d%d%d",&sz[0],&sz[1],&sz[2]);
    max=sz[0];
    for(i=0;i<3;i++)
    {
        if(sz[i]>max)
        {
            max=sz[i];
        }
    }
    s=0;
    for(i=0;i<3;i++)
    {
        if(sz[i]!=max)
            s=s+max-sz[i];
    }
    if(s%2==0)
        printf("%d\n",s/2);
    else
    {
        printf("%d\n",s/2+2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
using namespace std;

int main()
{
	int N;
	cin >> N;
 
	vector<int> A(N + 1);
	vector<int> B(N);
 
	for (int i = 0; i <= N; i++)
	{
		cin >> A[i];
	}
 
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}
 
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		int res1 = min(A[i], B[i]);
		ans += res1;
		B[i] -= res1;
		int res2 = min(A[i + 1], B[i]);
		ans += res2;
		A[i + 1] -= res2;
	}
 
	cout << ans << endl;
 
	return 0;
 
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#define rep(i,j,n) for(i=j;i<(n);i++)

using namespace std;

int main(){
    string s,t,a="No";
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<>());
    if(s<t){
        a="Yes";
    }
    cout<<a<<endl;
}


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

int main(){
	int n;

	cin >> n;

	int* a = new int[ n * 10 ];

	for ( int i = 0; i < n; ++i ){
		cin >> a[ i*10 + 0 ] >> a[ i*10 + 1 ] >> a[ i*10 + 2 ] >> a[ i*10 + 3 ] >> a[ i*10 + 4 ]
			>> a[ i*10 + 5 ] >> a[ i*10 + 6 ] >> a[ i*10 + 7 ] >> a[ i*10 + 8 ] >> a[ i*10 + 9 ];
	}

	for ( int i = 0; i < n; ++i ){
		int right = 0, left = 0;
		for ( int j = 0; j < 10; ++j ){
			int pick = a[ i*10 + j ];
			if ( pick < right && pick < left ){
				cout << "NO" << endl;
				break;
			}else if ( pick > right && pick < left ){
				right = pick;
			}else if ( pick < right && pick > left ){
				left = pick;
			}else if ( right > left ){
				right = pick;
			}else{
				left = pick;
			}
			if ( j == 9 ){
				cout << "YES" << endl;
			}
		}
	}

	delete[] a;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string tenki[3] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    if (s == tenki[0]) {
        cout << tenki[1] << "\n";
    } else if (s == tenki[1]) {
        cout << tenki[2] << "\n";
    } else {
        cout << tenki[0] << "\n";
    }
}

Measured memory_bytes: 256