akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        //それぞれの仕事でここまでにうけーてええでという基準日がある
        //その基準日を求めてそのなかの最大パｆｐのを渡す。かんじ・
        //かつおしりからつめていく
//        int[] c = new int[n];
//        for (int i = 0; i < n; i++) {
//            c[i] = m - a[i];
//        }
        List<Pair> list = new ArrayList<>();
        for (int i = 0 ; i < n ; i++) {
            Pair p = new Pair();
            p.from = a[i];
            p.end = b[i];
            list.add(p);
        }
        Collections.sort(list);

        int ans = 0;
        Queue<Integer> que = new PriorityQueue<>(Collections.reverseOrder());

        int index = 0;
        for (int i = 0 ; i <= m ; i++) {
            while (index < n &&  list.get(index).from <= i) {
                que.add(list.get(index).end);
                index++;
            }
            if (!que.isEmpty()) {
                ans += que.poll();
            }

        }

        System.out.println(ans);

    }

}


class Pair implements Comparable {
    int from;
    int end;


    @Override
    public int compareTo(Object other) {
        Pair otherpair = (Pair) other;
        int d = from - otherpair.from;
        if (d == 0) {
            return otherpair.end - end;
        } else {
            return d;
        }
    }

}

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


int main(){
    int L,R;
    cin >> L >> R;
    int ans=2019,l=L%2019;
    if(R-L-1>=2019){
        ans=0;
    }
    else{
        for(int i=l;i<l+R-L;++i){
            for(int j=i+1;j<=l+R-L;++j){
                ans = min(ans,(i*j)%2019);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b)
{
    ll r;
    r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

/*最小公倍数*/
ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    ll n, x,t=LLONG_MAX,m1=LLONG_MAX,m2=LLONG_MAX,sa1,g;
    cin >> n >> x;
    vector<ll> a(n);
    for (ll i = 0; i < n;i++){
        cin >> a[i];
    }
    g = abs(a[0] - x);
    for (ll i = 0; i < n; i++)
    {
        sa1 = abs(a[i] - x);
        g = gcd(g, sa1);
    }
    cout << g << endl;
}

Measured memory_bytes: 1024
using namespace std;
#include <bits/stdc++.h>
const int N = 2e5+5;
struct Edge{
    int to;
    int next;
}edge[N];
int n,m;
int tot,head[N];
void addEdge(int from,int to){
    edge[++tot].to=to;
    edge[tot].next=head[from];
    head[from]=tot;
}
bool dfs(int s,int step){
    if (s == n&&step == 2) return true;
    for(int i=head[s];i!=-1;i=edge[i].next){
        int to=edge[i].to;
        if (dfs(to,step+1)) return true;
    }
    return false;
}
int main() {
    memset(head,-1,sizeof(head));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        addEdge(x,y);
    }
    bool flag=dfs(1,0);
    if (flag) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main(void) {

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

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

	cout << lcm(a, b) << endl;

	return 0;
}



Measured memory_bytes: 3584
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B,ans;
  cin>>A>>B;
  if(A>=13) ans=B;
  else if(A<=12&&A>=6) ans=B/2;
  else ans=0;
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 384
#include<stdio.h>

int main () {
    int S, h, m, s;
    
    scanf("%d", &S);

    h = S / 3600;
    m = ( S - h * 3600) / 60;
    s = S % 60;

    printf("%d:%d:%d\n", h, m, s);

    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main() {
  int N;
  cin >> N;
  double x[N+10]={},ans=0;
  string v[N+10];
  for(int i=0; i<N; i++){
    cin >> x[i] >> v[i];
    if(v[i]=="JPY") ans+=x[i];
    else ans+=x[i]*380000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

// Out :
func Out(x ...interface{}) {
	//	fmt.Println(x...)
}

// GetInt :
func GetInt() int {
	var n int
	fmt.Scanf("%d", &n)
	return n
}

func main() {

	N := GetInt()

	Out(N)

	var c [10][10]int

	for i := 1; i <= N; i++ {
		lsb := i % 10
		msb := i % 10
		for v := i; v != 0; {
			msb = v % 10
			v /= 10
		}
		c[msb][lsb]++
		//	Out(i, msb, lsb)
	}

	//Out(c)
	sum := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			sum += c[i][j] * c[j][i]
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

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

  auto simulate = [&](ll x) {
    ll cnt = 0;
    rep(i, n)
    {
      ll t = a[i] + x;
      if (t <= n - 1)
        continue;
      cnt += CEIL(t - (n - 1), n + 1);
    }
    return cnt <= x;
  };

  ll sum = accumulate(a, a + n, 0LL);

  for (ll i = max(sum - 10000, 0LL); i <= sum + 10000; i++)
  {
    if (simulate(i))
    {
      cout << i << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] s = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			long max = 0L;
			for (int c = 1; c < n - 1; c++) {
				// indexを保存する用
				Set<Integer> set = new HashSet<>();
				long sum = 0L;
				for (int k = 1; k * c < n - 1; k++) {
					if ((n - 1 - c * k <= c) || set.contains(n - 1 - k * c) || set.contains(k * c)
							|| n - 1 - k * c == k * c) {
						break;
					}
					sum = sum + s[n - 1 - k * c] + s[k * c];
					max = Math.max(max, sum);
					set.add(n - 1 - k * c);
					set.add(k * c);
				}
			}
			System.out.println(max);
		}
	}
}


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

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

	vector<double> p(N);
	for(uint32_t i=0; i<N; i++) cin >> p[i];
	
	vector<vector<double>> dp(N+1, vector<double>(N+1, 1));
	
	for(uint32_t i=1; i<=N; i++) dp[i][0] = dp[i-1][0] * (1 - p[i-1]);
	for(uint32_t i=1; i<=N; i++) dp[i][i] = dp[i-1][i-1] * p[i-1];
	
	for(uint32_t i=2; i<=N; i++) {
		for(uint32_t j=1; j<i; j++) {
			dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1]);
		}
	}

	double ans = accumulate(dp[N].begin() + N/2 + 1, dp[N].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    int n1 = (w+1)/2;
    int n2 = w/2;
    int m1 = (h+1)/2;
    int m2 = h/2;
    ll ans = 1LL*n1*m1+1LL*n2*m2;
    cout << ans << endl;
}


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

using namespace std;

const int maxn = 1e5 * 3 + 20;
long long n, a[maxn], s;

int main()
{
	cin >> n;
	for (int i = 0; i < n * 3; i++)
	{
		cin >> a[i];
	}	
	sort (a , a + n * 3);
	for (int i = n; i < n * 3; i += 2)
	{
			s += a[i];
	}
	cout << s;
	return 0;
}


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

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

  vector<int> d(n);
  for (int i = 0; i < n; i++)
  {
    cin >> d[i];
  }

  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      sum += d[i] * d[j];
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#pragma GCC target("avx,avx2")
using namespace std;
using ll=long long ;
struct test{
  int id;
  ll b;
  ll l;
  ll u;

  ll get_plus(ll X)const{
    return (X-b)*u+l*b;
  }

  ll get_time(ll rest)const {
    if(b*l>=rest){
      return (rest-1)/l+1;
    }else{
      ll ans=b;
      rest-=b*l;
      return b+(rest-1)/u+1;
    }
  }
};
    
void solve(){
  int N;
  ll X;
  cin>>N>>X;
  vector<test>tests;

  ll rest=0;
  for(int i=0;i<N;++i){
    ll b,l,u;cin>>b>>l>>u;
    tests.push_back(test{i,b,l,u});
    rest+=b*l;
  }
 // cout<<rest<<endl;
 for(int i=0;i<tests.size();++i){
    //cout<<tests[i].get_plus(X)<<endl;
  }
  sort(tests.begin(),tests.end(),[&](const test&l,const test&r){
    ll l_plus=l.get_plus(X);
    ll r_plus=r.get_plus(X);
    return l_plus<r_plus;
  });
  
  ll answer=0;
  int id=tests.size()-1;
  while(true){
    if(id==-1)break;
    auto atest=tests[id];
    //cout<<atest.id<<endl;
    ll plus=atest.get_plus(X);
    if(rest>=plus){
      rest-=plus;
      answer+=X;
    }else{
      break;
    }
    id--;
  }
  //cout<<tests.size()<<endl;
  if(rest){
    //cout<<rest<<endl;
    //cout<<answer<<endl;
    ll min_time=1e18;
    assert(!tests.empty());
    for(int i=0;i<=id;++i){
      min_time=min(min_time,tests[i].get_time(rest));
      //cout<<tests[i].id<<" "<<tests[i].get_time(rest)<<endl;
    }
    if(id!=-1){
      auto atest=tests[id];
      //cout<<atest.id<<endl;
      ll plus=atest.get_plus(X);
      rest-=plus;
      
      assert(rest<0);
      for(int x=id;x<tests.size();++x){
        ll arest=rest+tests[x].get_plus(X);
        
        min_time=min(min_time,tests[x].get_time(arest));
      }
    }

    answer+=min_time;

  }
  
  cout<<answer<<endl;
}

int main(void){
  solve();


  return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define M 17
#define N (1<<(M+1))
#define no cout << "-1\n", 0

int ans[N];

int main()
{
    canhazfast();

    int m, k, r, n = 0;

    cin >> m >> k;
    r = 1<<m;
    retif(k >= (1<<m)) no;
    if (m == 1) {
        retif(k == 1) no;
        cout << "0 0 1 1\n";
        return 0;
    }
    ans[n++] = k;
    for (int i = 0; i < r; ++i) {
        ctif(i == k);
        ans[n++] = i;
    }
    ans[n++] = k;
    for (int i = r-1; i >= 0; --i) {
        ctif(i == k);
        ans[n++] = i;
    }
    for (int i = 0; i < n; ++i) cout << ans[i] << ' ';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    long n=gl();
	    long k= gl();
	    
	    long c=n;
	    long a=1;
	    while(c>0) {
	    	c--;
	    	if (a>k) {
	    		a+=k;
	    	} else {
	    		a=2*a;
	    	}
	    }

	    System.out.print(a);
//	    if (s.contains("AC")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, n;
	cin >> a >> b >> n;
	ll r = min(b - 1, n);
	ll ans = a * r / b - r / b * a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi l(n);
    rep(i,n)cin>>l[i];
    SORT(l);
    int ans=0;
    rep(i,n){
        Rep(j,i+1,n){
            int t=l[i]+l[j];
            int k=lower_bound(all(l),t)-l.begin();
            ans+=k-1-j;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (x,a) = get!(usize, usize);

    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}


Measured memory_bytes: 8572
n, m, x, y = map(int,input().split())
li_x = list(map(int,input().split()))
li_y = list(map(int,input().split()))

max_x = max(li_x)
min_y = min(li_y)

for i in range(x+1,y+1):
    if max_x < i <= min_y:
        print("No War")
        break
else:
    print("War")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    for (int i = 0; i < n; i++) {
      x[i] = sc.nextInt();
    }

    int[] x_org = x.clone();
    Arrays.sort(x);

    int m1 = x[(n - 1) / 2];
    int m2 = x[(n + 1) / 2];

    String[] b = new String[n];
    if (m1 == m2) {
      for (int i = 0; i < n; i++) {
        b[i] = String.valueOf(m1);
      }
    } else {
      for (int i = 0; i < n; i++) {
        if (x_org[i] <= m1) {
          b[i] = String.valueOf(m2);
        } else {
          b[i] = String.valueOf(m1);
        }
      }
    }

    System.out.println(String.join("\n", b));
  }
}


Measured memory_bytes: 85632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int k = -1;
  for (int i = 0; i <= N + 1; i++){
    if ((long long) i * (i - 1) / 2 == N){
      k = i;
      break;
    }
  }
  if (k == -1){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    vector<vector<int>> S(k);
    int num = 1;
    for (int i = 0; i < k; i++){
      for (int j = i + 1; j < k; j++){
        S[i].push_back(num);
        S[j].push_back(num);
        num++;
      }
    }
    cout << k << endl;
    for (int i = 0; i < k; i++){
      int sz = S[i].size();
      cout << sz;
      for (int j = 0; j < sz; j++){
        cout << ' ' << S[i][j];
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 4088
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    for(int i = 1; i < 10000; i++) {
        int s = i * 8 / 100;
        int t = i / 10;

        if(s == a && t == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

int n, k, h[101030], dp[102000];

int main(void){
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i] = INT_MAX/2;
    }
    dp[0] = 0;
    
    for(int i=0;i<n;i++) {
        for(int j=1;j<=k;j++){
            if( i+j <= n && dp[i] + abs( h[i] - h[i+j] ) < dp[i+j] ) {
                dp[i+j] = dp[i] + abs( h[i] - h[i+j] );
            }
        }
    }
    
    cout << dp[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

const INF: u64 = 1 << 60;

fn warshall_floyd(n: usize, mut edges: Vec<Vec<u64>>) -> Vec<Vec<u64>> {
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j]);
            }
        }
    }
    edges
}

struct Permutation {
    n: usize,
    idx: usize,
}
impl Permutation {
    fn new(n: usize) -> Permutation {
        Permutation { n: n, idx: 0 }
    }
}
impl Iterator for Permutation {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Vec<usize>> {
        let mut r = vec![0; self.n];
        let mut idx = self.idx;
        for k in 1..self.n {
            r[k] = idx % (k + 1);
            idx /= k + 1;
        }
        if idx > 0 {
            return None;
        }
        r.reverse();
        let mut b = vec![true; self.n];
        b[r[0]] = false;
        for k in 1..self.n {
            let mut count = 0;
            for j in 0..self.n {
                if b[j] {
                    if count == r[k] {
                        r[k] = j;
                        b[j] = false;
                        break;
                    }
                    count += 1;
                }
            }
        }
        self.idx += 1;
        return Some(r);
    }
}

fn calc_cost(edges: &Vec<Vec<u64>>, r: &Vec<usize>) -> u64 {
    let mut cost = 0;
    for i in 0..r.len() - 1 {
        cost += edges[r[i]][r[i + 1]];
    }
    cost
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (N, M, R) = (v[0], v[1], v[2]);
    let r: Vec<usize> = read_vec();
    let mut r = r.iter().map(|&r| r - 1).collect::<Vec<_>>();

    let mut edges = vec![vec![INF; N]; N];
    for i in 0..M {
        let mut v: Vec<usize> = read_vec();
        let (a, b, c) = (v[0] - 1, v[1] - 1, v[2]);
        edges[a][b] = c as u64;
        edges[b][a] = c as u64;
    }
    let edges = warshall_floyd(N, edges);
    let mut ans = std::u64::MAX;
    for ord in Permutation::new(R) {
        let mut ac = 0;
        for i in 1..R {
            let a = r[ord[i - 1]];
            let b = r[ord[i]];
            ac += edges[a][b];
        }
        ans = min(ans, ac);
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
 
using namespace std;
 
const int maxn=500005;
typedef long long ll;
 
int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}
 
ll x,y;
ll a,b;
 
ll n,k;
ll vis[maxn];

int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>x;
		for(int j=1;j<=x;j++)
		{
			cin>>y;
			vis[y]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]!=1)
			a++;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int w = fs.nextInt();
        final int[][] items = new int[n][2];
        for (int i = 0; i < n; i++) {
            items[i] = new int[] { fs.nextInt(), fs.nextInt() };
        }
        final long[] dp = new long[w + 1];
        for (int i = 0; i < n; i++) {
            for (int j = w; j >= 0; j--) {
                if (j >= items[i][0]) {
                    dp[j] = Math.max(dp[j], dp[j - items[i][0]] + items[i][1]);
                }
            }
        }
        System.out.println(dp[w]);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 33460
N=int(input())
A=list(map(int,input().split()))
A=sorted(A,reverse=True)
ans=0
for i in range((N//2)+1):
  for j in range(2):
    ans+=A[i]

if N%2==1:
  ans-=A[i]
else:
  ans=ans-(A[i]*2)

if N//2!=0:
  ans-=A[0]

print(max(ans,0))

Measured memory_bytes: 31484
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll n, dis[100010], a, b;

int main() {
	cin >> n >> a >> b;
	REP(i, n){
		cin >> dis[i];
	}
	ll ans = 0;
	int now = dis[0];
	for(int i = 1;i < n;i++){
		int cost = min((dis[i] - now) * a, b);
		now = dis[i];
		ans += cost;
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<string>
#include <numeric>
#include <utility>
#include<math.h>
#include<functional>
#include<queue>
#include<sstream>
#include<stack>
#include<algorithm>

int solve(int A,int B,int C){
    if((A==5&&B==5&&C==7)||(A==5&&B==7&&C==5)||(A==7&&B==5&&C==5))std::cout<<"YES";
    else std::cout<<"NO";
    return 0;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int A,B,C;
    std::cin>>A>>B>>C;
    return solve(A,B,C);
}


Measured memory_bytes: 256
from copy import deepcopy
s = input()

ans = 10**10
for i in range(len(s)):
    a = s[i]
    t = deepcopy(s)
    cnt = 0
    
    while len(set(list(t))) !=1:
        
        cnt +=1
        while True:
            S = ""
            for j in range(len(t)-1):
                if (t[j] == a) or (t[j+1] == a):
                    S +=a
                    #print(t,S,j,t[j],t[j+1],a)
                else:
                    S +=t[j]

            else:
                t = deepcopy(S)
                #print(S,cnt)
                break
    ans = min(ans,cnt)
    #print(S,t,i,ans)
print(ans)

Measured memory_bytes: 9160
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=50;
    char grid[2*MAXN][2*MAXN+1];
    void output(){
        for(int u=0;u<2*MAXN;u++){
            cout<<grid[u]<<'\n';
        }
    }
    void solve(){
        int w,b;
        cin>>w>>b;
        w--;b--;
        for(int u=0;u<MAXN;u++){
            for(int v=0;v<2*MAXN;v++){
                grid[u][v]='#';
            }
            if(u%2==0&&w){
                for(int v=0;v<2*MAXN&&w;v+=2){
                    grid[u][v]='.';
                    w--;
                }
            }
        }
        for(int u=2*MAXN-1;u>=MAXN;u--){
            for(int v=0;v<2*MAXN;v++){
                grid[u][v]='.';
            }
            if(u%2==1&&b){
                for(int v=0;v<2*MAXN&&b;v+=2){
                    grid[u][v]='#';
                    b--;
                }
            }
        }
        cout<<100<<" "<<100<<'\n';
        output();
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

int main() {
  ll n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  if (a == 0) {
    printf("0\n");
  } else {
    ll d = n / (a + b), r = n % (a + b);
    ll ans = d * a;
    if (r > a)
      ans += a;
    else
      ans += r;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();

		
		if (W >= S) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}


		sc.close();
	}

}


Measured memory_bytes: 35764
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    string S;
    
    cin >> S;

    string tmp;
    int ans = 0;
    for( int si = 0 ; si < S.length() ; si++ ){
        tmp = S.substr(si,1);
        if(tmp == "+") ans++;
        else ans--;
    }
    cout << ans;

    

}

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

long long gcd(long long C,long long D)
{
	if(C==0 || D==0)return 0;
	long long r;
	for(;;){
		r = C%D;
		if(r==0)break;
		C = D;
		D = r;
	}
		return D;
}

long long lcm(long long C,long long D)
{
	if(C==0 || D==0)return 0;
	long long E;
	E = C*(D/gcd(C,D));
	return E;
}

int main(){
	int N;
	cin >> N;
	long long A[110];
	long long B[110];
	
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	B[0] = A[0];
	for(int j=0; j<N-1; j++){
		 B[j+1] = lcm(A[j+1],B[j]);
	}
		cout << B[N-1] << endl;
} 

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

using namespace std;

#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 FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int p,q,r;
  cin>>p>>q>>r;
  if(p-q>=0&&p-r>=0){
    cout<<q+r<<endl;
  }else if(q-p>=0&&q-r>=0){
    cout<<p+r<<endl;
  }else{
    cout<<q+p<<endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
matrix = [[] for i in range(N)]
check1 = [0] * N
check1[0] = 1

for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    matrix[a].append(b)
    matrix[b].append(a)

for i in matrix[0]:
    if (N-1) in matrix[i]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 39960
#include <string.h>
#include<iostream>
#include<vector>
#define ll long long
using namespace std;


const int MAX_N=110;
const int MAX_W=100100;
const ll MAX_V=1000000000;

ll weight[MAX_N],value[MAX_N];
int N,W;
 

const ll INF=1LL<<60;

ll dp[MAX_N][MAX_W];

/*
    品0-iまでで重量sum_wとなるときの最大価値をdpに保存
    return でdp[i][sum_w]　を返すことで部分問題に分解する

    solveに際してはrec(N-1,W)で用いて解を返す
    (0indexなので品番は0-N-1)
 */
ll rec(int i,int sum_w)
{
    //負の品番は存在しないので価値0でリターン
    if(i==-1 ) return 0;

    //探索済みならそのまま返す
    if(dp[i][sum_w]!=-1) return dp[i][sum_w];

    ll res;
    //重量的に品iを選択できるとき
    if(sum_w-weight[i]>=0)
    {
        /*
            (i非選択)品i-1まででsum_w以下最大価値と
            (i選択)品i-1まででsum_w-weight[i]以下の最大価値+品iの価値
            の比較をして大きい方を取る
         */
        res=max(rec(i-1,sum_w),rec(i-1,sum_w-weight[i])+value[i]);
    }
    /*
        品iを選ぶ重量的余裕がなければ
        (i非選択)品i-1まででsum_w以下最大価値
        のみとりうる
    */
    else res=rec(i-1,sum_w);

    return dp[i][sum_w]=res;


}

int main()
{
    memset(dp,-1,sizeof(dp));

    cin>>N>>W;

    for(int i=0;i<N;++i)
    {
        cin>>weight[i]>>value[i];
    }

    cout<<rec(N-1,W)<<endl;
}

Measured memory_bytes: 86272
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
using namespace std;
 
int const MAX_N = 128 * 1024;
 
int main() {
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    
	int a,b,c;
	cin>>a>>b>>c;
	int x;
	cin>>x;
	int cnt= 0;
	for (int i=0; i<=a; i++)
		for (int j=0; j<=b; j++)
			for (int k=0; k<=c; k++)
				cnt += i*500+j*100+k*50 == x;
	cout<<cnt;
    return 0;
}  


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


int main(){
 
  int n,m,c; cin>>n>>m>>c;
  vector<int> vecb(m);
  vector<vector<int>> veca(n,vector<int>(m));
  for(int i=0;i<m;i++){
    cin>>vecb[i];
  }

  int count=0;
  for(int i=0;i<n;i++){
    int sum=c;
     for(int j=0;j<m;j++){
         cin>>veca[i][j];
         sum+=veca[i][j]*vecb[j];
     }
    if(sum>0)count++;
  }
  cout<<count<<endl;

}

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

#define N 200000

int main(void){
	int a[N], b[N];
	int i, j, n;

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

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

	for(i=0; i<n; i++){
		printf("%d ", b[i]);
	}
	printf("\n");


	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;

const ll INF = 1e18;

int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
	cin >> n;

	vector<int> num(n + 1);
	for(i = 0; i <= n; i++) {
		cin >> num[i];
	}

	if(n == 0) {
		if(num[0] == 1) {
			cout << 1;
			return 0;
		}
		cout << -1;
		return 0;
	}

	vector<ll> nodes(n + 1);
	nodes[0] = 1;

	for(i = 0; i <= n; i++) {
		nodes[i] -= num[i];	
		//cerr << i << "  " << nodes[i] << "\n";
		if(nodes[i] < 0) {
			cout << -1;
			return 0;
		}
		if(i < n) {
			nodes[i + 1] += 2LL * nodes[i];
			nodes[i + 1] = min(nodes[i + 1], INF);
		}
	}
	
	nodes[n] = 0;

	ll ans = 0;
	for(i = n; i >= 0; i--) {
		nodes[i] += num[i];
		ans += nodes[i];
		if(i > 0) {
			nodes[i - 1] = min(nodes[i - 1], nodes[i]);
		}
	}

	cout << ans;

    return 0;
}


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

#define M 100010

int main(void){
    vector<bool> prime(M,true),f(M);
    prime[0] = prime[1] = false;
    rep(i,M){
        if(!prime[i])continue;
        for(int j=i*2;j<M;j+=i){
            prime[j] = false;
        }
    }
    rep(i,M){
        if(prime[i] && prime[(i+1)/2]){
            f[i] = true;
        }
    }
    vector<int> imos(M);
    rep(i,M-1){
        imos[i] += f[i];
        imos[i+1] = imos[i];
    }
    int q;
    cin>>q;
    rep(_,q){
        int l,r;
        cin>>l>>r;
        cout<<imos[r]-imos[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static List<int> refrigeratorList = new List<int>();
    static List<int> microwaveList = new List<int>();
    static List<int[]> discountTicketList = new List<int[]>();
    static int minPrice = 0;
  
    static void Main(string[] args)
    {
        int[] inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int A = inputs[0];
        int B = inputs[1];
        int M = inputs[2];

        refrigeratorList.AddRange(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());
        microwaveList.AddRange(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());

        for(int i = 0;i < M;i++)
        {
            int[] tickets = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            discountTicketList.Add(tickets);
        }

        minPrice = refrigeratorList.Min() +  microwaveList.Min();
        discountTicketList.ForEach(x => tryBuy(x));

        Console.WriteLine(minPrice);
    }

    static void tryBuy(int[] ticket) {
        
        int targetRG = ticket[0] - 1;
        int targetMW = ticket[1] - 1;
        int discountAmount = ticket[2];
        
        int price = (refrigeratorList[targetRG] + microwaveList[targetMW]) - discountAmount;
        if(price < minPrice) {
            minPrice = price;
        }
    }
}

Measured memory_bytes: 38620
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    vector<int>v(n+1,0),w(n+1,0);
    for(int i=1;i<=n;++i){
        cin>>v[i]>>w[i];
    }
    vector<vector<int>>dp(1<<9,vector<int>(100001,0));
    for(int i=1;i<=min(n, (1<<9)-1);++i){
        for(int j=1;j<=100000;++j){
            int p=i/2;
            dp[i][j]=max(dp[p][j], dp[i][j-1]);
            if(j-w[i]>=0){
                dp[i][j]=max(dp[p][j-w[i]]+v[i], dp[i][j]);
            }
        }
    }
    int q;
    cin>>q;
    for(int i=0;i<q;++i){
        int t,L;
        cin>>t>>L;
        vector<int>vv,ww;
        while(t>=(1<<9)){
            vv.push_back(v[t]);
            ww.push_back(w[t]);
            t/=2;
        }
        int n=vv.size();
        int res=0;
        for(int j=0;j<(1<<n);++j){
            int val=0,wei=0;
            for(int k=0;k<n;++k){
                if((j>>k) & 1){
                    val+=vv[k];
                    wei+=ww[k];
                }
            }
            if(L-wei>=0){
                res=max(res,val+dp[t][L-wei]);
            }else{
                continue;
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 206544
#include<iostream>
using namespace std;
int main(){
  int N = 0;
  cin >> N;
  int judge = N%10;
  string text = "hon";
  if(judge == 3) text ="bon";
  else if(judge == 0 || judge == 1 || judge == 6 || judge == 8) text = "pon";
  cout << text << endl;
  return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    for(int n=0;n<a*b;n++){
        for(int m=0;m<a*b;m++){
            if(a*m == n*b + c){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static int[][] m = new int[][] {{0,300,500,600,700,1350,1650},
									{0,  0,350,450,600,1150,1500},
									{0,  0,  0,250,400,1000,1350},
									{0,  0,  0,  0,250, 850,1300},
									{0,  0,  0,  0,  0, 600,1150},
									{0,  0,  0,  0,  0, 0,  500},
									{0,0,0,0,0,0,0}
								   };
	static int[][] l = new int[][] {{0,6,13,18,23,43,58},
									{0,0,7 ,12,17,37,52},
									{0,0,0 ,5 ,10,30,45},
									{0,0,0 ,0 ,5 ,25,40},
									{0,0,0 ,0 ,0 ,20,35},
									{0,0,0 ,0 ,0 ,0 ,15},
									{0,0,0 ,0 ,0 ,0 ,0 }
								   };
	public static void main(String[]agrs){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int s = sc.nextInt();
			if(s == 0) break;
			int h1 = sc.nextInt();
			int m1 = sc.nextInt();
			int g = sc.nextInt();
			int h2 = sc.nextInt();
			int m2 = sc.nextInt();
			
			int len = l[s-1][g-1];
			int mon = m[s-1][g-1];
			
			if(len <= 40 && ((h1*60 + m1) >= (17*60 + 30) || (h2*60 + m2) <= (19*60 + 30))) {
				mon /= 2;
			}
			if(mon % 50 != 0) {
				mon += 50 - (mon % 50);
			}
			System.out.println(mon);
		}
	}
}

Measured memory_bytes: 20452
#include<stdio.h>
#include<stdlib.h>

int cmpfunc(const void*a, const void*b){
    return(*(int*)a-*(int*)b);}
int main(){

    int n,i,c=0,k=0,j,m[100000]={0};
    scanf("%ld",&n);
    long long int a[n];

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

    qsort(a, n, sizeof(long long int),cmpfunc);

    for(i=0;i<n;i++){
        if(a[i]==a[i+1]){
            m[k]++;}
        else
            k++;}
     if(k==n)
        c=k;
    else{
    for(i=0;i<k;i++){
        if(m[i]%2==0)c++;
        }}
    printf("%ld",c);}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;
vector<ll> a;

int main(){
    cin >> N;
    a.resize(N);
    rep(i,N){
        cin >> a[i];
    }

    deque<ll> dq;
    rep(i,N){
        if(i%2==0) dq.push_front(a[i]);
        else dq.push_back(a[i]);
    }

    if(N%2==1){
        for(int i=0;i<N;i++){
            cout << dq[i];
            if(i<N-1) cout << " ";
        }
        cout << endl;
    }
    else{
        for(int i=N-1;i>=0;i--){
            cout << dq[i];
            if(i>0) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>
#define MAX 20000001
#define VMAX 10000


void CountingSort(unsigned short *A, unsigned short *B, int n){
  int i,j;
  int C[VMAX+1];
  for ( i = 0; i<=VMAX; i++)
    C[i] = 0;

  /* C[i] に i の出現数を記録する */
  for (j = 1; j<=n; j++)
    C[A[j]]++;

  /* C[i] に i 以下の数の出現数を記録する*/
  for ( i = 1; i<= VMAX; i++)
    C[i] = C[i] + C[i-1];

  for (j = n; j>0 ; j--){
    B[C[A[j]]] = A[j];      
    C[A[j]]--;
  }
}
  
void print(unsigned short *A, int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}


int main(){
  unsigned short *A, *B;
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for ( i = 1; i <= n; i++ ) scanf("%hu", &A[i]);
  
  CountingSort(A,B,n);
  
  print(B,n);

  return 0;
}



Measured memory_bytes: 9580
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i128,
        k: u128,
        d: u128,
    }
    let xabs = x.abs() as u128;
    if k <= xabs / d {
        println!("{}", xabs - k * d);
        return;
    }
    let kleft = k - xabs / d;
    if kleft % 2 == 0 {
        println!("{}", xabs % d);
    } else {
        println!("{}", d - (xabs % d));
    }
}


Measured memory_bytes: 2200