akhauriyash/Code-Regression huggingface dataset:
import sys
import copy
import time

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

D = None
C = None
S = None

def cnt_score(t):
    global D, C, S
    score = 0
    cnt = [-1] * 26

    for i in range(D):
        score += S[i][t[i] - 1]
        minusscore = 0
        cnt[t[i] - 1] = i
        for j in range(26):
            minusscore += (i - cnt[j]) * C[j]
        score -= minusscore
    return score


def main():
    global D, C, S
    D = int(input())
    C = [int(x) for x in input().split()]
    S = [[int(x) for x in input().split()] for _ in range(D)]

    start = time.time()

    ans = []
    for s in S:
        #ans.append(s.index(max(s)) + 1)
        ans.append(C.index(max(C)) + 1)

    #ans = [1] * D

    day = 0
    while True:
        # time up
        current = time.time()
        if current - start > 1.9:
            break

        # main
        new_ans = copy.deepcopy(ans)
        old_score = cnt_score(ans)

        max_sore = old_score
        max_contest = ans[day]
        for i in range(26):
            new_ans[day] = i + 1
            new_score = cnt_score(new_ans)
            if new_score > old_score:
                max_contest = i + 1
                old_score = new_score
        ans[day] = max_contest

        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72732
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define epsilon 0.0000001
using namespace std;


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (b < a || (n==1 && b!= a)) {
    cout << 0 << endl;
  } else {
    cout << (n-2) * (b - a) + 1;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll N, H;
    cin >> N >> H;
    vector<ll> p1(N), p2(N);
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        p1[i] = a;
        p2[i] = b;
    }
    sort(all(p1), greater<ll>());
    sort(all(p2), greater<ll>());
    ll firstMax = p1[0];
    ll count = 0;
    rep(i, N){
        if(p2[i] < firstMax) break;
        H -= p2[i];
        count++;
        if(H <= 0){
            H = 0;
            break;
        }
    }
    cout << count + (H + p1[0] - 1) / p1[0] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    priority_queue<pair<ll, int>> Q;
    
    rep(i, n) {
        ll a;
        cin >> a;
        Q.push(make_pair(a, 1));
    }

    rep(i, m) {
        int b;
        ll c;
        cin >> b >> c;
        Q.push(make_pair(c, b));
    }

    ll ans = 0;
    rep(i, n) {
        auto x = Q.top();
        Q.pop();
        ans += x.first;
        x.second--;
        if(x.second >= 1) {
            Q.push(x);
        }
    }

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

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    vector<ll>b(n);
    ll med1, med2;
    rep(i, 0, n){
        cin >> a[i];
        b[i] =  a[i]; 
    }
    sort(b.begin(),b.end());
    med1 = b[n/2-1];
    med2 = b[n/2];
    rep(i, 0, n){
        if(a[i] <= med1)cout << med2 <<endl;
        else cout << med1 <<endl;
    }
}

Measured memory_bytes: 5376
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

#define N_MAX 200000
#define MODVAL 1000000007

int main(void){
	int n;
	int m;
	int h[100000];
	int j[100000] = {};
	int i;
	int a,b;
	int ret;

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

	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		if(h[a-1] > h[b-1]){
			j[b-1] = -1;
		}else if(h[a-1] < h[b-1]){
			j[a-1] = -1;
		}else{
			j[a-1] = -1;
			j[b-1] = -1;
		}
	}

	ret = 0;
	for(i=0;i<n;i++){
		if(j[i] != -1){
			ret++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2504
fn solve(s: String, t: String) -> usize {
    let s = s.chars().collect::<Vec<_>>();
    let t = t.chars().collect::<Vec<_>>();

    let mut ans = 0;
    for i in 0..3 {
        ans += if s[i] == t[i] { 1 } else { 0 };
    }

    ans
}

#[test]
fn solve_test() {
    assert_eq!(solve("CSS".to_owned(), "CSR".to_owned()), 2);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let s = read_line!();
    let t = read_line!();
    println!("{}", solve(s, t));
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

const int N = 505;
int in[N][N];
vector< int> ans;


void chk(int i, int j) {
    while (i != j) {
        ans.emplace_back(i);
        i++;
    }
}


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

    vector< pair< int, int> > Vp;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            scanf("%d", &in[i][j]);
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (i & 1) for (int j = 1; j <= m; ++j) Vp.emplace_back(i, j);
        else for (int j = m; j >= 1; j--) Vp.emplace_back(i, j);
    }

    for (int i = 0; i < n * m; i++) {
        int x = Vp[i].first, y = Vp[i].second;
        if (in[x][y] % 2 == 0) continue;
        for (int j = i + 1; j < n * m; ++j) {
            int a = Vp[j].first, b = Vp[j].second;
            if (in[a][b] & 1) {
                chk(i, j);
                i = j;
                break;
            }
        }
    }

    cout << ans.size() << endl;
    for (int &t : ans) {
        printf("%d %d %d %d\n", Vp[t].first, Vp[t].second, Vp[t + 1].first, Vp[t + 1].second);
    }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  for (int i = 0; i < m; i++) {
    cin >> l.at(i) >> r.at(i);
  }
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  int ans = max(0, r.at(0) - l.at(m - 1) + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3960
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let (n, m): (usize, u64) = input();
    let mut v: Vec<u64> = input();
    for i in 1..n { v[i] += v[i - 1]; }

    let mut map: BTreeMap<u64, u64> = BTreeMap::new();
    map.insert(0, 1);
    for x in v {
        *map.entry(x % m).or_insert(0) += 1;
    }

    println!("{}", map.values().map(|&x| x * (x - 1) / 2).sum::<u64>());
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 6396
#include <stdio.h>
int main(void) {
    int H, W, i, j;
    while (scanf("%d %d", &H, &W) == 2) {
        if (H == 0 && W == 0) break;
        for (i = 1; i < H + 1; i ++) {
            if (i == 1 || i == H) {
                for (j = 1; j < W + 1; j ++) printf("#");
                printf("\n");
            }
            j = 1;
            if (i >= 2 && i < H) {
                    if (j == 1) printf("#");
                    for (j = 2; j < W; j ++) printf(".");
                    printf("#\n");
            }
        } 
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 588
#ITP1_9_D
S=input()
n=int(input())
for j in range(n):
  M=list(map(str,input().split()))
  a=int(M[1])
  b=int(M[2])
  if(M[0]=="print"):
    print(S[a:b+1])
  elif M[0]=="reverse":
    S=S[:a]+S[a:b+1][::-1]+S[b+1:]
  elif M[0]=="replace":
    S=S[:a]+M[3]+S[b+1:]

  


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

struct Edge {
  int to, cost, time;
  Edge(int to, int cost, int time) : to(to), cost(cost), time(time) {}
};

i64 dp[50][2551];

void solve() {
  int n, m, s;
  cin >> n >> m >> s;
  amin(s, 2500);
  vector<vector<Edge>> g(n);
  rep(i, m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    g[u].emplace_back(v, a, b);
    g[v].emplace_back(u, a, b);
  }
  vi32 cs(n), ds(n);
  rep(i, n) {
    int c, d;
    cin >> c >> d;
    cs[i] = c, ds[i] = d;
  }
  rep(i, 50) repc(j, 2550) {
    dp[i][j] = 1e18;
  }
  pqasc<tuple<i64, int, int>> q;
  q.emplace(0, s, 0);
  while (sz(q)) {
    i64 t;
    int s, u;
    tie(t, s, u) = q.top(), q.pop();
    if (dp[u][s] != 1e18) continue;
    dp[u][s] = t;
    if (s + cs[u] <= 2550 && dp[u][s + cs[u]] == 1e18) {
      q.emplace(t + ds[u], s + cs[u], u);
    }
    each(e, g[u]) {
      if (s - e.cost < 0) continue;
      q.emplace(t + e.time, s - e.cost, e.to);
    }
  }
  reps(i, n - 1) {
    i64 ans = 1e18;
    repc(j, 2550) amin(ans, dp[i][j]);
    cout << ans << endl;
  }
}


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

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans=0;
  for(int r=0;r<=R;r++){
    for(int g=0;g<=G;g++){
      if(N-500*r-100*g>=0&& (N-500*r-100*g)%50==0 && (N-500*r-100*g)/50<=B)ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

import Math._
object Main extends App {
  val eps0 = 1e-12

  val Seq(xp1, yp1, xp2, yp2) = readLine.split(' ').map(_.toDouble).toList
  val vx1 = xp2 - xp1
  val vy1 = yp2 - yp1


  val q = readLine.toInt
  for (i <- 0 until q) {
    val Seq(x, y) = readLine.split(' ').map(_.toDouble).toList
    val vx2 = x - xp1
    val vy2 = y - yp1

    val rot = vx1 * vy2 - vy1 * vx2

    println(if (rot.abs < eps0) {
      if (vx1 * vx2 + vy1 * vy2 < 0) {
        "ONLINE_BACK"
      } else {
        if (vx2*vx2 + vy2*vy2 > vx1*vx1 + vy1*vy1) "ONLINE_FRONT" else "ON_SEGMENT"
      }
    } else {
      if (rot > 0) "COUNTER_CLOCKWISE" else "CLOCKWISE"
    })
  }
}



Measured memory_bytes: 45864
import java.util.Scanner;
class Main{
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int t=sc.nextInt();
			int n=sc.nextInt();
			int S=1;
			int A=2;
			int B=3;
			int C=4;
			int  ans=0;
			if(t==S){
				 ans=6000*n;
			} if(t==A){
				ans=4000*n;
			} if(t==B){
				ans=3000*n;
			}  if(t==C){
				ans=n*2000;
			}
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 17360
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<int> as,bs;

void solve(){
    cin >> n;
    bs.resize(n,0);
    rep(i,n){
        int a;
        cin >> a;
        as.push_back(a);

    }
    rep(i,n){
        bs[0]+=pow(-1,i)*as[i];
    }
    rep(i,n-1){
        bs[i+1]=2*as[i]-bs[i];
    }
    rep(i,n){
        cout << bs[i] << endl;
    }
    
}

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

Measured memory_bytes: 2296
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
for i in range(1,m):
  for j in range(i+1,m+1):
    if sc[i-1][0]==sc[j-1][0] and sc[i-1][1]!=sc[j-1][1]:
      print(-1)
      exit()
 
for t in range(1,m+1):
  if n>=2 and sc[t-1]==[1,0]:
    print(-1)
    exit()
 
ans=[0]*n
for t in range(1,m+1):
  if ans[sc[t-1][0]-1]==0:
    ans[sc[t-1][0]-1]+=sc[t-1][1]
    
if ans[0]==0 and n>=2:
  ans[0]=1
print(*ans,sep='')

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

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

int main(){
  ll x;
  cin>>x;
  ll money =100;
  int count = 0;
  while(money < x){
    money*=1.01;
    count++;
  }
  cout<<count;

}


Measured memory_bytes: 3628
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

class UnionFind {
private:
    vector<Int> _par, _siz;

public:
    UnionFind(Int sz) : _par(sz), _siz(sz, 1LL) {
        for (Int i = 0; i < sz; i++) {
            _par[i] = i;
        }
    }

    Int root(Int x) {
        while (_par[x] != x) {
            x = _par[x] = _par[_par[x]];
        }
        return x;
    }

    bool merge(Int x, Int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }

        if (_siz[x] < _siz[y]) {
            swap(x, y);
        }
        _siz[x] += _siz[y];
        _par[y] = x;

        return true;
    }

    bool issame(Int x, Int y) {
        return root(x) == root(y);
    }

    Int size(Int x) {
        return _siz[root(x)];
    }

    ~UnionFind(){};
};

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

    Int n, m;
    cin >> n >> m;
    vector<pair<Int, Int>> edge;
    for (Int i = 0; i < m; i++) {
        Int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge.push_back({a, b});
    }

    Int ans = 0;
    for (Int i = 0; i < m; i++) {
        UnionFind uf(n);
        for (Int k = 0; k < m; k++) {
            if (k != i) {
                uf.merge(edge[k].first, edge[k].second);
            }
        }

        if (!uf.issame(edge[i].first, edge[i].second)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(void)
{
    int num;
    scanf("%d", &num);

    if(num%10 == 0 || num%10 == 1 || num%10 == 6 ||num%10 == 8 ) {
        printf("pon\n");
    } else if(num%10 == 3) {
        printf("bon\n");
    } else {
        printf("hon\n");
    }

    return 0;
}

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

int main() {
    int n,W;cin>>n>>W;long long w[n],v[n];
    long long dp[n+1][W+1];

    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int sum_w=0;sum_w<=W;sum_w++){
            if(sum_w-w[i]>=0){
                dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
            }
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
        }
    }
    cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104
#include<stdio.h>
#include<string.h>
int main()
{
	char s[105],t[105],x;
	int i,n,d=0,j;
	scanf("%s%s",&s,&t);
	n=strlen(s);
	for(i=0;i<n;i++)
	{
		if(strcmp(s,t)==0)
		{d=1;break;}
	    else 
		{
		x=s[n-1];
		for(j=n-2;j>=0;j--)
		{s[j+1]=s[j];}
		s[0]=x;
		}
	}
	if(d==1)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
  int  a;
  scanf("%d",&a);
  bool b;
  for(int f=3;f<=a;f++){
      b=false;
  if(f%3==0)b=true;
  string c=to_string(f);
  for(char d:c){
      if(d=='3')b=true;
      }
      if(b)printf(" %d",f);
      }
      printf("\n");
}

Measured memory_bytes: 3196
int main(void)
{
    int n,i,j;
    scanf("%d",&n);
     
    for(i = 3;i <= n;i++){
        j = i;
        if(i % 3 == 0)printf(" %d",i);
        else       
        while(j > 0){
            if(j % 10 == 3){
                printf(" %d",i);
                break;
            }
            j /= 10;
        }   
    }
             
    printf("\n");
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

// extends vector to negative indices
template <typename T = lnt>
struct Evec
{
	int n;
	std::vector<T> data;
	Evec(int n, T init) : n(n),data(2*n+1, init) {}
	T& operator[](const int& i) {
		return data[i+n];
	}
};


int main() {
	int x,n;
	std::cin >> x >> n;
	std::vector<int> v(150,true);
	rep(i,n) {
		int p;
		std::cin >> p;
		v[p]=false;
	}
	int mind=1000;
	int ans;
	for(int i=x;i<150;i++) {
		if(v[i]) {
			mind=i-x;
			ans=i;
			break;
		}
	}
	for(int i=x;i>=0;i--) {
		if(v[i]&&mind>=x-i) {
			ans=i;
			break;
		}
	}
	print(ans);
}


Measured memory_bytes: 3660
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;
template<int VW, int VH> struct Ruisekiwa2D {
	using T = int;
	T v[VH][VW];
	Ruisekiwa2D() { REP(y, VH) REP(x, VW) v[y][x] = 0; }
	void set(int x, int y, T c) { v[y][x] = c; }
	void add(int x, int y, T c) { v[y][x] += c; }
	void build() {
		REP(y, VH) REP(x, VW) {
			if (0 < y) v[y][x] += v[y - 1][x];
			if (0 < x) v[y][x] += v[y][x - 1];
			if (0 < y && 0 < x) v[y][x] -= v[y - 1][x - 1];
		}
	}
	T get(int sx, int sy, int tx, int ty) { // [sx,sy]～[tx,ty]
		if (tx < sx or ty < sy) return 0;
		T rs = v[ty][tx];
		if (0 < sx) rs -= v[ty][sx - 1];
		if (0 < sy) rs -= v[sy - 1][tx];
		if (0 < sx && 0 < sy) rs += v[sy - 1][sx - 1];
		return rs;
	}
	T getToDown(int x, int y, int len) {
		if (VH - y < len) len = VH - y;
		return get(x, x, y, y + len - 1);
	}
	T getToUp(int x, int y, int len) {
		if (y + 1 < len) len = y + 1;
		return get(x, x, y - len + 1, y);
	}
};
int H, W;
Ruisekiwa2D<2010, 2010> sum, sum1, sum2;

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

	int Q;
	cin >> H >> W >> Q;
	VS S(H);
	REP(i, H)cin >> S[i];
	REP(i, H)REP(j, W) {
		if (S[i][j] == '1') {
			sum.add(i, j, 1);
			if (i + 1 < H&&S[i + 1][j] == '1')sum1.add(i, j, 1);
			if (j + 1 < W&&S[i][j + 1] == '1')sum2.add(i, j, 1);
		}	
	}
	sum.build();
	sum1.build();
	sum2.build();
	while (Q--) {
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		x1--, y1--, x2--, y2--;
		int ans = sum.get(x1, y1, x2, y2);
		//cout << ans << endl;
		x2--, y2--;
		if (x1 <= x2)ans -= sum1.get(x1, y1, x2, y2 + 1);
		if (y1 <= y2)ans -= sum2.get(x1, y1, x2 + 1, y2);
		cout << ans << '\n';
	}

	return 0;
}



Measured memory_bytes: 102180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	rep(i, K) {
		if (i % 2 == 0) {
			if (A % 2 != 0) {
				A--;
			}
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2 != 0) {
				B--;
			}
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
t1 = 0
t2 = 0
i = 0
j = 1
while (i + j) <= N:
    if t1 <= t2:
        t1 += W[i]
        i += 1
    elif t1 >= t2:
        t2 += W[-j]
        j += 1
    #print(t1,t2)
print(abs(t1-t2))


Measured memory_bytes: 3060
from numpy import*
n=int(input())
f=array([list(map(int,input().split()))for i in range(n)])
p=array([list(map(int,input().split()))for i in range(n)])
print(max(sum(p[k][v]for k,v in enumerate(sum(f*array([i>>j&1for j in range(10)]),axis=1)))for i in range(1,1024)))

Measured memory_bytes: 12512
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int M=557,mod=1e9+7,mx=400;
LL read(){
	LL ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
LL n,c;
LL A[M],B[M],p[M][M],f[M][M];
int main(){
	n=read(); c=read();
	for(int i=1;i<=n;i++) A[i]=read();
	for(int i=1;i<=n;i++) B[i]=read();
	for(int i=1;i<=mx;i++) p[i][0]=1;
	for(int i=1;i<=mx;i++)
		for(int j=1;j<=c;j++) p[i][j]=p[i][j-1]*i%mod;
	for(int i=1;i<=mx;i++)
		for(int j=0;j<=c;j++) p[i][j]=(p[i][j]+p[i-1][j])%mod;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	for(int j=0;j<=c;j++)
	for(int m=0;m<=j;m++)
	f[i][j]=(f[i][j]+f[i-1][j-m]*(((p[B[i]][m]-p[A[i]-1][m])%mod+mod)%mod))%mod;
	printf("%lld\n",f[n][c]);
	return 0;
}

Measured memory_bytes: 4472
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define bitcount                __builtin_popcount
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)                __gcd(a,b)
#define lcm(a, b)                ((a)*(b))/gcd(a,b)
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    bool flag=true;
    ll n,m,sum=0,cnt=0;
    cin>>n>>m;
    int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    sort(arr,arr+n);
    double res=(sum*1.0/(4*m));
    
    for (int i=0;i<n;i++)
    {
        if (arr[i]>=res) cnt++;

    }
    if (cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;

struct UndirectedGraph
{
    using Pint = pair<int, int>;
    using Plint = pair<lint, int>;
    int V;
    int E;
    vector<lint> weights;
    vector<vector<Pint>> to;
    vector<Pint> edges;

    UndirectedGraph(int V) : V(V), E(0),
                             to(vector<vector<Pint>>(V)) {}

    void add_edge(int v1, int v2, lint w)
    {
        to[v1].push_back(Pint(v2, E));
        to[v2].push_back(Pint(v1, E));
        edges.push_back(Pint(v1, v2));
        weights.push_back(w);
        E++;
    }

    vector<lint> dist;
    void dijkstra(int start)
    {
        dist = vector<lint>(V, -1);
        priority_queue<Plint, vector<Plint>, greater<Plint>> pq;
        pq.push(Plint(0, start));

        while (!pq.empty()) {
            Plint p = pq.top(); pq.pop();
            int v = p.second;
            if (dist[v] >= 0 && dist[v] <= p.first) continue;
            dist[v] = p.first;
            // cout << "dist[" << v << "] = " << p.first << endl;
            for (auto vnxt : to[v]) {
                lint dnxt = dist[v] + weights[vnxt.second];
                if (dnxt < dist[vnxt.first] || dist[vnxt.first] < 0) {
                    pq.push(Plint(dnxt, vnxt.first));
                }
            }
        }
    }

    vector<lint> patterns(int s, vector<lint> &d)
    {
        vector<lint> ans(V); ans[s] = 1;
        priority_queue<Plint, vector<Plint>, greater<Plint>> pq;
        for (int i = 0; i < V; i++) pq.push(Plint(d[i], i));
        while (!pq.empty())
        {
            Plint p = pq.top(); pq.pop();
            for (auto v : to[p.second]) if (d[v.first] + weights[v.second] == p.first) (ans[p.second] += ans[v.first]) %= MOD;
        }
        return ans;
    }
};

int N, M, S, T;

int main()
{
    cin >> N >> M >> S >> T;
    S--; T--;

    UndirectedGraph graph(N);
    for (int i = 0; i < M; i++)
    {
        int u, v, d;
        cin >> u >> v >> d;
        u--; v--;
        graph.add_edge(u, v, d);
    }


    graph.dijkstra(S);
    vector<lint> dist_f = graph.dist;
    vector<lint> dp1 = graph.patterns(S, dist_f);

    graph.dijkstra(T);
    vector<lint> dist_b = graph.dist;
    vector<lint> dp2 = graph.patterns(T, dist_b);

    lint ans = 0;

    lint D = dist_f[T];
    for (int i = 0; i < N; i++) if (dist_f[i] * 2 == D) (ans += (dp1[i] * dp2[i] % MOD) * (dp1[i] * dp2[i] % MOD)) %= MOD;
    for (int i = 0; i < M; i++)
    {
        int v1 = graph.edges[i].first;
        int v2 = graph.edges[i].second;
        if (dist_f[v1] > dist_f[v2]) swap(v1, v2);
        if (dist_f[v1] * 2 < D && dist_b[v2] * 2 < D && dist_f[v1] + dist_b[v2] + graph.weights[i] == D)
        {
            (ans += (dp1[v1] * dp2[v2] % MOD) * (dp1[v1] * dp2[v2] % MOD)) %= MOD;
        }
    }
    cout << (dp1[T] * dp1[T] - ans + MOD) % MOD << endl;
}


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

int main() {
  int n,x;
  int t;
  while(cin>>n>>x&&n!=0||x!=0){
  int count=0;
  for (int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
       t=x-j-i;
        if((t<=n)&&(t>j)){count++;}}
    }
  cout<<count<<endl;}
  return 0;
}


Measured memory_bytes: 3120
n = int(input())
s = input()

bad_count = 0

for middle in range(1, n - 1):
	left = middle - 1
	right = middle + 1
	while left >= 0 and right < n:
		if s[middle] != s[left] and s[middle] != s[right] and s[right] != s[left]:
			bad_count += 1

#			print(left, middle, right)

		left -= 1
		right += 1

left_r = 0
left_g = 0
left_b = 0
right_r = 0
right_g = 0
right_b = 0

for c in s:
	if c == 'R':
		right_r += 1
	elif c == 'G':
		right_g += 1
	else:
		right_b += 1

good_count = 0

for c in s:
	if (c == 'R'):
		good_count += left_b * right_g
		good_count += right_b * left_g
		left_r += 1
		right_r -= 1
	elif c == 'G':
		good_count += left_r * right_b
		good_count += right_r * left_b
		left_g += 1
		right_g -= 1
	else:
		good_count += left_r * right_g
		good_count += right_r * left_g
		left_b += 1
		right_b -= 1

print(good_count - bad_count)

Measured memory_bytes: 67812
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


void uku(){cout<<"No"<<endl; exit(0);}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  cin>>A;
  for(auto &I:A){I--;}
  vector<pll> tmp(N);
  for(int i=0;i<N;i++){tmp[i]={A[i],i};}
  sort(tmp.begin(),tmp.end());
  vector<ll> ans(N*N,-1);
  queue<ll> Q;
  for(auto &I:tmp){
    if(ans[I.F]!=-1){uku();}
    ans[I.F]=I.S;
  }
  for(int i=0;i<N*N;i++){if(ans[i]==-1){Q.push(i);}}
  for(auto &I:tmp){
    //cout<<ans<<endl;
    for(int j=0;j<I.S;j++){
      assert(!Q.empty());
      if(Q.front()>I.F){uku();}
      ans[Q.front()]=I.S;
      Q.pop();
    }
    //cout<<I.S<<endl;
  }
  //cout<<ans<<endl;
  stack<ll> S;
  while(!Q.empty()){S.push(Q.front()); Q.pop();}
  reverse(tmp.begin(),tmp.end());
  for(auto &I:tmp){
    for(int j=0;j<N-I.S-1;j++){
      assert(!S.empty());
      if(S.top()<I.F){uku();}
      ans[S.top()]=I.S;
      S.pop();
    }
  }
  cout<<"Yes"<<endl;
  for(auto &I:ans){I++;}
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint x,k,d,v;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k) cout<<x-k*d;
    else if((k-x/d)%2) cout<<abs(x%d-d);
    else cout<<x%d;
    return 0;
}
/*
1000000000000000 1 10000000000000
*/


Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    string A;
    cin >> A;
    vector<ll> v(26, 0);
    ll len = A.size();
//    ll len = 200000;
    rep(i, 0, A.size()) {
        v[A[i] - 'a']++;
    }

    ll ans = 1LL + (len * (len - 1)) / 2;

    rep(i, 0, 26) {
        ans -= (1LL) * (v[i] * (v[i] - 1)) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
d={}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d.update({s:1})

m = int(input())
for j in range(m):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d.update({t:-1})
print("0" if max(d.values()) < 0 else max(d.values()))

Measured memory_bytes: 3064
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll n, k;
    VE pos, neg;
    cin >> n >> k;
    ll X;
    pos.push_back(0);
    neg.push_back(0);
    REP(i, n){
        cin >> X;
        if(X >= 0){pos.push_back(X);}
        else{neg.push_back(-X);}
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    ll ans = mod;
    RREP(i, pos.size()){
        if(k - i >= neg.size())continue;
        ans = min(ans, pos[i] * 2 + neg[k - i]);
        ans = min(ans, pos[i] + neg[k - i] * 2);
    }
    RREP(i, neg.size()){
        if(k - i >= pos.size())continue;
        ans = min(ans, neg[i] * 2 + pos[k - i]);
        ans = min(ans, neg[i] + pos[k - i] * 2);
    }
    print(ans);
}


Measured memory_bytes: 1656
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  // cout << s << ' ' << t << endl;
  char x = s[0];
  bool ok =false;
  for(int i=0;i<t.length();i++){
    if(x<t[i]){
      ok=true;
      break;
    }
  }
  bool blah = false;
  if(s.length()<t.length()){
    blah=true;
    for(int i=0;i<s.length();i++){
      if(s[i]==t[i]){
        continue;
      }
      else{
        blah=false;
        break;
      }
    }
  }
  if(ok || blah)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

const int N = 1e5 + 7;

int n, m;
int p[N];
long long cnt;
long long sz[N];

int get(int v) {
    if (v == p[v]) return v;
    return p[v] = get(p[v]);
}

void merge(int a, int b) {
    a = get(a);
    b = get(b);
    if (a != b) {
        if (sz[a] < sz[b]) swap(a, b);
        cnt -= sz[a] * 1LL * sz[b];
        p[b] = a;
        sz[a] += sz[b];
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    vector <pair <int, int> > e;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        e.push_back({u, v});
    }
    reverse(e.begin(), e.end());
    for (int i = 1; i <= n; i++) {
        p[i] = i;
        sz[i] = 1;
    }
    cnt = n * 1LL * (n - 1) / 2;
    vector <long long> ans;
    for (int i = 0; i < m; i++) {
        ans.push_back(cnt);
        merge(e[i].first, e[i].second);
    }
    reverse(ans.begin(), ans.end());
    for (long long x : ans) {
        cout << x << '\n';
    }
    return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define sqrt(d) pow((long double) (d), 0.50)
 
const ll INF = 2e9;
const ll large_P = 1e9 + 7;
 
 
int main(){
  ll N; cin >> N;
  ll res = 0;
  
  rep(i, N){
    if( (i+1)%3 != 0 && (i+1)%5 != 0 ) res += i+1;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3624
h,w = map(int,input().split())

if h*w % 2 == 0:
  if h == 1 or w == 1:
    print(1)
  else:  
    print(h*w//2)  

if h*w % 2 == 1:
  if h == 1 or w == 1:
    print(1)
  else:  
    print(h*w//2+1)

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

int main(){
    string s; cin >> s;
    int count = 0;
    rep(0,i,s.size()){
        if(s[i]=='1') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
from heapq import *

def main():
	x, y, z, k, *L = map(int, open(0).read().split())
	s = sorted
	a = s(L[:x])[::-1]
	b = s(L[x:x + y])[::-1]
	c = s(L[x + y:])[::-1]
	h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
	done = {(0, 0, 0)}
	for _ in range(k):
		v, i, j, k = heappop(h)
		print(-v)
		for ni, nj, nk in ((i + 1, j, k), (i, j + 1, k), (i, j, k + 1)):
			if ni == x or nj == y or nk == z:
				continue
			if (ni, nj, nk) not in done:
				heappush(h,(-(a[ni] + b[nj] + c[nk]), ni, nj, nk))
				done.add((ni, nj, nk))

if __name__=="__main__":
	main()

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

bool is_prime(int x){ 
	if(x<=1) return false;
	for(int i=2;i*i<=x;i++){
		if(x%i==0) return false; 
    }
	return true;
}

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

	int p=x;
	while(!is_prime(p)) p++;

	cout<<p<<endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        s:chars
    }

    let mut ans = true;
    for i in 0..s.len() {
        if i % 2 == 0 {
            if s[i] == 'L' {
                ans = false;
                break;
            }
        } else if i % 2 == 1 {
            if s[i] == 'R' {
                ans = false;
                break;
            }
        }

    }
    println!("{}", if ans { "Yes" } else { "No" });

}


Measured memory_bytes: 4352
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows!* * * * * * */
#include      <bits/stdc++.h>
using namespace std;
#define IOS       ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC      cout.precision (10); cout << fixed
#ifdef CONVICTION
#include "/home/convict/Dropbox/myfiles/sport_coding/cplib/snippets/debug.h"
#else
#define debug(x...)
#endif
//Don’t practice until you get it right. Practice until you can’t get it wrong

void preproc() {
}

void solve() {
   int N;
   cin >> N;
   vector <int> ar(N);
   vector <int> pref(N), suff(N);
   for (int i = 0; i < N; ++i) {
      cin >> ar[i];
      pref[i] = (i ? pref[i - 1] : 0) ^ ar[i];
   }
   for (int i = N-1; i >= 0; --i) {
      suff[i] = (i == N-1 ? 0 : suff[i+1]) ^ ar[i];
   }

   for (int i = 0; i < N; ++i) {
      ar[i] = (i ? pref[i-1] : 0) ^ (i == N-1 ? 0 : suff[i+1]);
      cout << ar[i] << " \n"[i == N-1];
   }
}

signed main() {
  IOS; PREC;
  preproc();

  int tc = 1;
  // cin >> tc;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    // cout << "Case #" << Tt << ": ";
    solve();
  }
  return EXIT_SUCCESS;
}


Measured memory_bytes: 5552
N = int(input())
#print(N)
K = int(input())
#print(K)
X = int(input())
#print(X)
Y = int(input())
#print(Y)

Z = N - K
#print(Z)
#print()

if Z >= 0:
    mae = K * X
    ato = Z * Y
    print(mae + ato)
else:
    print(N * X)

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

using namespace std;

struct land {
	int gm;
	int mx;
};

bool operator<(const land& x, const land& y)
{
  return x.mx < y.mx;
}

int main(){
	int n;
	while(1){	
		vector <land> data;
		cin >> n;
		if(!n) break;	
		for(int i=0;i < n;i++){
			land p;
			cin >> p.gm >> p.mx;
			data.push_back(p);
		}	
		sort(data.begin(),data.end());	
		if(data[0].gm > data[0].mx) cout << "No" << endl;
		else {
			int flag = 1;
			for(int i=1;i < n;i++){
			 data[i].gm += data[i-1].gm;
			 if(data[i].gm > data[i].mx){flag = 0;break;}
			}
			if(flag) cout << "Yes" << endl;
			else cout << "No" << endl;
		}		
	}
	return 0;
}

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

using namespace std;
using ll = long long int;
#define INF 20000000000000000
#define MOD 1000000007

int main(void){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++) cin >> a[i];
  
  sort(a.begin(), a.end());
  
  cout << a[a.size()-1] - a[0] << endl;
  
}

Measured memory_bytes: 256