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

using namespace std;

int main(){

    vector<int> p;

    int k,n; cin >> n >> k;

    for(int i=0;i<n;i++){
        int x; cin >> x; p.push_back(x);
    }

    sort(p.begin(),p.end());

    int ans = 0;
    for(int i=0;i<k;i++){
        ans+=p[i];
    }    

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

Measured memory_bytes: 3636
(defun solve (n playlist x)
  (declare (ignore n))
  (loop for ((title . s) . rest) on playlist
        if (string= title x)
        do (return
             (loop for (nil . time) in rest
                   summing time))))

#-swank
(let* ((n (read))
       (playlist (loop repeat n
                       for line = (read-line)
                       for pos = (position #\Space line)
                       collect (cons (subseq line 0 pos)
                                     (parse-integer line :start (1+ pos)))))
       (x (read-line)))
  (format t "~A~%" (solve n playlist x)))


Measured memory_bytes: 16100
/* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1194&lang=jp */
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#include<cassert>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;

int main() {
	int R,N;
	int xl,xr,h;
	int offset = 20;
	cout << fixed << setprecision(4); //固定でかつ浮動小数点誤差範囲

	while(cin >> R >> N)
	{
		if (R == 0 && N == 0) { break; }
		vector<int> max_hs(50,0); //-20<=i<=20

		rep(i,N) {
			cin >> xl >> xr >> h;
			xl = xl + offset;
			xr = xr + offset;
			for(int x = xl; x < xr; x++) { //-2<=x<=-1(点) -> -2<=x<-1(線分)
				max_hs[x] = max(max_hs[x],h);
			}
		}

		/*
		 * ここでのx0,y0とは円の中心座標
		 * y0_left, y0_rightはビルの頂点の左右の点のこと
		 */
		double mini = INT_MAX;
		double y0=0;
		int y=0;
		for(int x = -R; x < R; x++) {
			int xx = x+offset; //配列用のx座標
			y = max_hs[xx];

			int tmp_x = 0;
			if (x < 0) { tmp_x = x+1; } //-2点| -2線 | -1点 | -1線 | 0点 | 0線 | ...
			else { tmp_x = x; }

			//R分のオフセットあり
			y0 = y - sqrt(R*R - tmp_x*tmp_x); //建物の左側または右側の特徴点(x0=0)
			y0 = y0 + R; //中心から距離R上の円上の座標
			chmin(mini,y0);
		}
		cout << mini << endl;
	}

	return 0;
}

Measured memory_bytes: 1272
/**
*    author:  Dooloper
*    created: 03.09.2020 19:36:23
**/
#include <bits/stdc++.h>
using namespace std;

#define A 1000006

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

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

  bool pairwise = true;
  for (int i = 2; i < A; ++i) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) {
      pairwise = false;
      break;
    }
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  for (int i = 0; i < n; ++i) {
    g = gcd(g, a[i]);
    if (g == 1) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "not coprime" << endl;

  return 0;
}

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

ll g1(ll n, ll p){
    if(n==0) return 0;
    return n/p + g1(n/p, p);
}

ll g2(ll n, ll p){
    if(n%2) return g1(n,p)-g2(n-1,p);
    else{
        ll ans = g1(n/2,p);
        if(p==2) ans+=n/2;
        return ans;
    }
}


int main(){
    ll n;
    cin>>n;
    cout<< min(g2(n,2),g2(n,5))<< endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
 
public class Main {    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> num = new ArrayList<Integer>();

        long money = 1000;
        num.add(sc.nextInt());
        for(int i=0;i<n-1;i++){
            int p = sc.nextInt();
            if(num.get(num.size()-1)!=p){
                num.add(p);
            }
        }
//        System.out.println(num);
        for(int i=0;i<num.size();i++){
            int p = -1;
            int min = num.get(i);
            for(int l=i+1;l<num.size();l++){
                if(min<num.get(l)){
                    p = l;
                    break;
                }else{
                    min = num.get(l);
                }
            }
            if(p!=-1){
                money += (num.get(p)-min) * (money/min);
            }else{
                break;
            }
            i = p -1;
        }
        System.out.println(money);
    }
}

Measured memory_bytes: 35956
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

int n;
//map<array<int, 3>, int> dp;
vector<int> a;

// int f(int i, int j, int k){
//     if(j < 0 || k < 0) return 0;
//     if(i==n) return j;
//     if(dp.count({i,j,k})) return dp[{i,j,k}];
    
//     int ans = 0;
//     for(int buy = 0; buy <= j/a[i]; ++buy){
//         ans = max(ans, f(i+1, j-buy*a[i], k+buy));
//     }
//     for(int sell = 0; sell <= k; ++sell){
//         ans = max(ans, f(i+1, j+sell*a[i], k-sell));
//     }

//     return dp[{i,j,k}] = ans;
// }

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

    ll money = 1000;
    for(int i = 1; i < n; ++i){
        if(a[i-1] < a[i]){
            ll stocks = money/a[i-1];
            money += stocks*(a[i]-a[i-1]); 
        }
    }

    cout << money << '\n';
    //cout << f(0, 1000, 0) << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0;
    cin>>n;
    string s;
    map <string,long long> dict;
    f(i,0,n){
        cin>>s;
        dict[s]++;
        if(dict[s]==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    pair<pair<string,int>,int> p[110];

    for(int i = 0; i < n; i++){
        string a;
        int b;
        cin >> a >> b;
        p[i] = make_pair(make_pair(a,-b),i);
    }
    sort(p,p+n);
    for(int i = 0; i < n; i++){
        cout << p[i].second+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
const int MAXN = 1e7 + 1;
int n, x, y, f, c, i, j, spf[MAXN];
long long ans = 1, z;
int main()
{
	for (i = 2; i < MAXN; i += 2)
        spf[i] = 2;
	for (i = 3; i < MAXN; i += 2)
        spf[i] = i;
    for (i = 3; i < 3162; i += 2)
        if (spf[i] == i)
            for (j = i * i; j < MAXN; j += i)
                if (spf[j] == j)
                    spf[j] = i;
	scanf("%d", &n);
	for (i = 2; i <= n; ++i)
	{
		x = i, f = 1, c = 1, z = 1;
		while (x > 1)
			y = spf[x], x /= y, y > f ? z *= c, c = 2, f = y : ++c;
		ans += i * z * c;
	}
	printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 40760
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){

  string S;
  cin >> S;
  map<char, int> m;
  for(int i=0; i < S.size(); i++){
    m[S[i]] += 1;
  }

  string ans = "No";
  if(m.size() == 2){
    bool flag = true;
    for(auto iter = m.begin(); iter != m.end(); iter++){
      int v;
      v = iter->second;
      if(v != 2){
        flag = false;
        break;
      }
    }
    if(flag){
      ans = "Yes";
    }
  }

  cout << ans << endl;

}

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

int main() {
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    int maxa = -1;
    rep(i, N) {
        cin >> a[i] >> b[i];
        maxa = max(maxa, a[i]);
    }
    sort(b.begin(), b.end(), greater<int>());

    int res = 0;
    rep(i, N) {
        if(b[i] > maxa) {
            res++;
            H -= b[i];
        }
        if(H <= 0) {
            cout << res << endl;
            return 0;
        }
    }
    if(H%maxa) res = res + (H/maxa) + 1;
    else res = res + (H/maxa);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1152
import java.io.*;
import java.util.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int k = saori.saori_hayami();
		int ans = 0;
		for(int i = 100; k > 0;i--){
			if(a%i == 0 && b%i == 0){
				k--;
				ans = i;
			}
		}
		System.out.println(ans);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;
typedef pair<double, double> PDD;

const int MAX_N = 2e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    string s;
    cin >> s;

    int ans;
    if (s == "MON") {
        ans = 6;
    }
    if (s == "TUE") {
        ans = 5;
    }
    if (s == "WED") {
        ans = 4;
    }
    if (s == "THU") {
        ans = 3;
    }
    if (s == "FRI") {
        ans = 2;
    }
    if (s == "SAT") {
        ans = 1;
    }
    if (s == "SUN") {
        ans = 7;
    }

    cout << ans;

    return 0;
}


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

int main() {
  int ans=0;
  string s;
  cin>>s;
  if(s[0]=='1')ans++;
  if(s[1]=='1')ans++;
  if(s[2]=='1')ans++;
  cout<<ans<<endl;
  

  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

    int N,D;
    scanf("%d",&D);
    scanf("%d",&N);

    switch(D){
        case 0:if(N != 100){
                printf("%d",N);
             }else{
                printf("%d",101);
            }   break;
        
        case 1:
            if(N != 100){
                printf("%d", 100 * N);
            }else{
                printf("%d",10100);
            }   break;
        
        case 2:
           if(N != 100){
               printf("%d",10000 * N);
           }else{
               printf("%d",1010000);
           }    break;

    }   
    return 0;

    
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int D;
  cin >> D;
  switch (D) {
  case 22:
    cout << "Christmas Eve Eve Eve" << endl;
    break;
  case 23:
    cout << "Christmas Eve Eve" << endl;
    break;
  case 24:
    cout << "Christmas Eve" << endl;
    break;
  case 25:
    cout << "Christmas" << endl;
    break;
  default:
    return -1;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

k=n_in()
a,b=l_in()

for i in range(a,b+1):
    if i%k == 0:
        print('OK')
        exit()
else:
    print('NG')
        


Measured memory_bytes: 61880
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let mut l = -1_000_000_000_i64;
    let mut r = -l; // ng

    let calc = |b: i64| {
        let mut s = 0_i64;
        for i in 0..N {
            s += (A[i] - (i + 1) as i64 - b).abs()
        }
        s
    };

    let ok = |m: i64| calc(m + 1) - calc(m) <= 0;

    while r - l > 1 {
        let m = l + (r - l) / 2;

        if ok(m) {
            l = m;
        } else {
            r = m;
        }
    }

    println!("{}", calc(l + 1));

    return;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

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

    ll ans1,ans2;

    if(a>=k){
        ans1=a-k;
        ans2=b;
    }else{
        ans1=0;
        k-=a;
        if(b>=k){
            ans2=b-k;
        }else{
            ans2=0;
        }
        
    }

    cout<<ans1<<" "<<ans2<<"\n";

    return 0;
}

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

using namespace std;

struct node{
  unsigned int key;
  node *next;
  node *prev;
};

typedef struct node* NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer n;
  for(n = nil->next; n != nil; n = n->next){
    if(n->key == key){
      return n;
    }
  }
  return nil;
}

void init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0 )  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  /*NodePointer n;
  for(n = nil->next; n != nil; n = n->next);
  deleteNode(n->prev);*/
  deleteNode(nil->prev);
}

void todelete(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x;
  x = (NodePointer)malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  
  nil->next->prev = x;
  nil->next = x;
}

int main(){
  int n;
  int key;
  string comma;

  scanf("%d", &n);
  init();
  
  for (int i = 0; i < n; i++ ){
    cin >> comma;
    if ( comma == "insert" ){
      scanf("%d", &key);
      insert(key);
    }
    else if ( comma == "delete" ){
      scanf("%d", &key);
      todelete(key);
    }
    else if ( comma == "deleteFirst" ) deleteFirst();
    else if ( comma == "deleteLast" ) deleteLast();
  }
  
  printList();
  return 0;
}



Measured memory_bytes: 34444
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, M = 1e9 + 7, N = 51;

int n, k;

V<vi> mul(V<vi> a, V<vi> b) {
	V<vi> c(n, vi(n));
	for(int i = 0; i < n; i++) 
		for(int j = 0; j < n; j++)
			for(int k = 0; k < n; k++) 
				c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % M;
	return c;
}

V<vi> qpow(V<vi> a, int b) {
	if(b == 0) {
		V<vi> a(n, vi(n));
		for(int i = 0; i < n; i++) a[i][i] = 1;
		return a;
	}
	auto c = qpow(a, b / 2);
	c = mul(c, c);
	if(b & 1) return mul(c, a);
	else return c;
}

signed main()
{
	IO_OP;
	
	cin >> n >> k;
	V<vi> a(n, vi(n));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	a = qpow(a, k);
	int ans = 0;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) ans = (ans + a[i][j]) % M;
	cout << ans << endl;

}



Measured memory_bytes: 4932
#include <cinttypes>
#include <cstdint>
#include <cstdio>
#include <algorithm>
using ui16 = std::uint_fast16_t;
using ui32 = std::uint_fast32_t;
using ui64 = std::uint_fast64_t;
using std::scanf;
using std::printf;
const ui32 W_MAX = 100000;
ui64 F[W_MAX + static_cast<ui32>(1)];
int main()
{
	ui16 N;
	ui32 W, w, v;
	scanf("%" SCNuFAST16 "%" SCNuFAST32, &N, &W);
	while (N--)
	{
		scanf("%" SCNuFAST32 "%" SCNuFAST32, &w, &v);
		for (ui32 i = W; i >= w; --i)
			F[i] = std::max(F[i], F[i - w] + static_cast<ui64>(v));
	}
	printf("%" PRIuFAST64 "\n", F[W]);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <functional>

template <class Data, class Operator>
class LazySegmentTree {
    using DataMerger = std::function<Data(Data, Data)>;
    using OperatorMerger = std::function<Operator(Operator, Operator)>;
    using Applier = std::function<Data(Data, Operator, int)>;

public:
    int length;
    std::vector<Data> dat;
    std::vector<Operator> ope;
    Data dat_id;
    Operator ope_id;
    DataMerger datm;
    OperatorMerger opem;
    Applier app;

    explicit LazySegmentTree(int N, Data dat_id, Operator ope_id, DataMerger datm, OperatorMerger opem, Applier app)
        : length(1), dat_id(dat_id), ope_id(ope_id), datm(datm), opem(opem), app(app) {
        while (length < N) length *= 2;
        dat.assign(length * 2, dat_id);
        ope.assign(length * 2, ope_id);
    }

    void eval(int nidx, int len) {
        if (ope[nidx] == ope_id) return;
        // 子に作用素を伝播
        if (nidx * 2 + 1 < length * 2) {
            ope[nidx * 2] = opem(ope[nidx * 2], ope[nidx]);
            ope[nidx * 2 + 1] = opem(ope[nidx * 2 + 1], ope[nidx]);
        }
        // 値に作用素を反映
        dat[nidx] = app(dat[nidx], ope[nidx], len);
        ope[nidx] = ope_id;
    }

    // half-open interval [ql, qr)
    Data update(int ql, int qr, Operator e) { return update(ql, qr, e, 1, 0, length); }
    Data update(int ql, int qr, Operator e, int nidx, int nl, int nr) {
        eval(nidx, nr - nl);
        if (nr <= ql || qr <= nl) return dat[nidx];
        if (ql <= nl && nr <= qr) {
            ope[nidx] = opem(ope[nidx], e);
            return app(dat[nidx], ope[nidx], nr - nl);
        }
        // 子を再帰的に更新
        Data vl = update(ql, qr, e, nidx * 2, nl, (nl + nr) / 2);
        Data vr = update(ql, qr, e, nidx * 2 + 1, (nl + nr) / 2, nr);
        // 子の更新後から値を更新
        return dat[nidx] = datm(vl, vr);
    }

    // half-open interval [ql, qr)
    Data query(int ql, int qr) { return query(ql, qr, 1, 0, length); }
    Data query(int ql, int qr, int nidx, int nl, int nr) {
        eval(nidx, nr - nl);
        if (nr <= ql || qr <= nl) return dat_id;
        if (ql <= nl && nr <= qr) return dat[nidx];
        Data vl = query(ql, qr, nidx * 2, nl, (nl + nr) / 2);
        Data vr = query(ql, qr, nidx * 2 + 1, (nl + nr) / 2, nr);
        return datm(vl, vr);
    }
};

using ll = long long;

int main() {
    int N, Q;
    std::cin >> N >> Q;
    LazySegmentTree<ll, ll> seg(N, 0, 0,
                                [](ll a, ll b) { return a + b; },
                                [](ll e, ll f) { return e + f; },
                                [](ll a, ll e, int k) { return a + e * k; });

    for (int q = 0; q < Q; ++q) {
        int k;
        std::cin >> k;
        if (k == 0) {
            int l, r, x;
            std::cin >> l >> r >> x;
            seg.update(l - 1, r, x);
        } else {
            int l, r;
            std::cin >> l >> r;
            std::cout << seg.query(l - 1, r) << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7052
# dp[i][j] i個目までの荷物を使って重さjまでとなるのときの最大の価値

N, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(1, W+1):
        if a[i][0] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-a[i][0]]+a[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 120044
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <deque>
#include <queue>
#include <map>
using namespace std;

#define ii pair <int, int>
#define lli long long
#define pb push_back
#define X first
#define Y second

const int Mod = 1E9 + 7;
const int Inf = 1E9 + 7;
const int N = 2E5 + 10;

int n;
ii a[N];

void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i].X >> a[i].Y;
}

bool cmp(ii x, ii y)
{
    return x.Y < y.Y;
}

void Solve()
{
    for (int i = 1; i <= n; i++) {
        int x = a[i].X + a[i].Y;
        int y = a[i].X - a[i].Y;
        a[i] = {x, y};
    }

    sort(a + 1, a + 1 + n);
    int res = a[n].X - a[1].X;
    sort(a + 1, a + 1 + n, cmp);
    res = max(res, a[n].Y - a[1].Y);
    cout << res;

}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    int testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}




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

int main(){
    int N;
    cin>>N;
    vector<int> s(N);

    int odd = 300;
    int sum = 0;

    for(int i=0; i<N;i++){
        cin>>s[i];
        sum += s[i];
        if(s[i]%10) odd = min(odd,s[i]);
    }

    if(odd == 300 && !(sum%10)) sum = 0;
    else if(!(sum%10)) sum -= odd;

    cout<<sum<<endl;

   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100006;

string s,t;
int n;

bool ok() {
    int ti = 0;
    for(auto x:s) {
        if(x==t[ti]) ti++;
        if(ti==3) return true;
    }
    return false;
}

int main() {
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<1000;i++) {
        t = to_string(i);
        while(t.size()<3) t = '0'+t;
        if(ok()) ans++;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdlib.h>
#define rp(i,n)for(int i=0;i<n;i++)
up(const int*a,const int*b){return *a-*b;}
n,m,x[100002],a[100002],sum=0;
main(){
scanf("%d%d",&n,&m);
rp(i,m)scanf("%d",&x[i]);qsort(x,m,sizeof(int),up);
rp(i,m-1)a[i]=x[i+1]-x[i];qsort(a,m-1,sizeof(int),up);
rp(i,m-n)sum+=a[i];printf("%d",sum);
}


Measured memory_bytes: 2884
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

ll dp[111][2][4];

int getNum(char c) {
    return (int)(c - '0');
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    int K;
    cin >> S >> K;
    int N = (int)S.size();
    dp[0][0][0] = 1;
    rep(i, 0, N) rep(j, 0, 2) rep(k, 0, K + 1) {
        int max_d = j ? 10 : getNum(S[i]) + 1;
        rep(d, 0, max_d) {
            if (k + (d > 0) > K) {
                continue;
            }
            dp[i + 1][j | (getNum(S[i]) > d)][k + (d > 0)] += dp[i][j][k];
        }
    }
    cout << dp[N][0][K] + dp[N][1][K] << endl;
    return 0;
}

Measured memory_bytes: 256
from math import sqrt
n = int(input())
a = 1+8*n
b = int(sqrt(a))
if b**2 != a or b%2==0:
    print("No")
    exit()
else:
    k = (1 + b)//2
    s = [[] for i in range(k)]
    cur = 1
    for i in range(k):
        for j in range(k-i-1):
            s[i].append(cur)
            s[i+j+1].append(cur)
            cur += 1
    print("Yes")
    print(k)
    for i in range(k):
        res = "{} ".format(len(s[i])) + " ".join(map(str, s[i]))
        print(res)

Measured memory_bytes: 9156
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

int main(){
  int a,b;
  while(1){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    if(a > b) cout << b << " " << a << endl;
    else cout << a << " " << b << endl;
  }
  
  return 0;
}


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

using namespace std;

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

  int a,b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    cout << a + b << "\n";
  } else {
    cout << a - b << "\n";
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) gcd(b, a);
	long long  r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {
	if (b == 0) { p = 1; q = 0; return a; }
	long long d = extGcd(b, a%b, q, p);
	q -= a / b * p;
	return d;
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
//amari,mod,amari,mod
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
	long long p, q;
	long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
	if ((b2 - b1) % d != 0) return make_pair(0, -1);
	long long m = m1 * (m2 / d); // lcm of (m1, m2)
	long long tmp = (b2 - b1) / d * p % (m2 / d);
	long long r = mod(b1 + m1 * tmp, m);
	return make_pair(r, m);
}
typedef pair<long long,long long>p;
vector<int>graph[100004];
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	long long num[33] = { 0 };
	long long ans = (long long)s.size()*(s.size() - 1) / 2;
	for (int i = 0; i < s.size(); i++) {
		num[s[i] - 'a'] += 1;
	}
	for (int i = 0; i <= 'z' - 'a'; i++) {
		ans -= num[i]*(num[i] - 1) / 2;
	}
	cout << ans+1;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  string s;
  ll k;
  cin >> s >> k;

  char c;
  for (int i = 0; i < k; i++) {
    if(s[i] == '1') {
      c = s[i];
      continue;
    }
    else {
      c = s[i];
      break;
    }
  }

  cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string str;
  int count = 0;
  cin >> str;
  for(int i = 0,n = str.length();i < n; i++)
  {
    if(str[i] != str[n-i-1])
      count++;
  }
  cout << count/2 << endl;
return 0;
}

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	long long n;
	scanf("%lld",&n);
	long long sum=0;
	int i, a;
	for(i=1;i<=n;i++){
		a = i;
		if(i%3 == 0 || i%5 == 0){
			a = 0;
		}
		sum += a;
	}
	printf("%lld\n",sum);
    return 0; 
}


Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

const int Maxn = 2010;
const int Inf = 0x7fffffff;

int n , k , q , ans = Inf;
int a[Maxn];
int tmp[Maxn] , Q[Maxn];

int main() {
	
	scanf("%d%d%d",&n,&k,&q);
	for(register int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	
	for(register int i=1; i<=n; i++) {
		Q[0] = 0;
		for(register int j=1; j<=n+1; j++) {
			if(a[j] < a[i]) {
				sort(tmp+1,tmp+tmp[0]+1);
				for(register int x=1; x<=tmp[0]-k+1; x++)
					Q[++Q[0]] = tmp[x];
				tmp[0] = 0;
			}
			else	tmp[++tmp[0]] = a[j];
		}
		sort(tmp+1,tmp+tmp[0]+1);
		for(register int x=1; x<=tmp[0]-k+1; x++)
			Q[++Q[0]] = tmp[x];
		tmp[0] = 0;
		if(Q[0] < q)	continue;
		sort(Q+1,Q+Q[0]+1);
		ans = min(ans,Q[q]-a[i]);
	}
	
	printf("%d\n",ans);
	
	return 0;
	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n;
    cin >> n;
    n %= 10;
    if(n == 3){
        cout << "bon" << endl;
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}


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

int n;
int main()
{
    scanf("%d", &n);
    int Min = 10000000;
    for(int a = 1; a <= n / 2 + n % 2 ; ++a){
        int b = n - a;
        int sc = 0;
        int x = a;
        while(x > 0) sc += (x % 10), x /= 10;
        while(b > 0) sc += (b % 10), b /= 10;
        Min = min(Min, sc);
    }
    printf("%d", Min);

    return 0;
}


Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int r, g;
    cin >> r >> g;
    cout << r + 2 * (g - r) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
    ll n;
    double t,a;cin>>n>>t>>a;
    ll h[n];rep(i,0,n)cin>>h[i];
    double ans=abs(a-t+h[0]*0.006); ll b=1;
    rep(i,0,n)if(ans>abs(a-t+h[i]*0.006)){ans=abs(a-t+h[i]*0.006);b=i+1;}
    cout<<b<<endl;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
one=(n-1)//2
two=(n+3)//2
s_1 = s[:one]
s_2 = s[two-1:]
if s_1 == list(reversed(s_1)):
    if s_2 == list(reversed(s_2)):
        if s == list(reversed(s)):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

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

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

  map<string,int> m{};

  for(int i = 0; i < N; i++) {
    string v;
    getline(cin, v);
    if(m.count(v) == 0) {
      m.emplace(v, 1);
    } else if(m.count(v) == 1) {
      m[v]++;
    }
  }

  int maxValue = 0;
  for (pair<string, int> p: m){
    maxValue = max(maxValue, p.second);
  }

  for (pair<string, int> p: m){
    if(m[p.first] == maxValue) {
      cout << p.first << endl;
    }
  }
}


Measured memory_bytes: 26624
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
   int n,k;
   cin>>n>>k;
   int arr[n];
   for (int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   sort (arr,arr+n);
   int sum=0;
   for (int i=0;i<k;i++)
   {
       sum+=arr[i];
   }
   cout<<sum;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010],b[100010];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<=n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		cin>>b[i];
		ll now=min(a[i],b[i]);
		ans+=now;
		b[i]-=now;
		now=min(a[i+1],b[i]);
		ans+=now;
		a[i+1]-=now;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n, k, q;
	cin >> n;
	cin >> k;
	cin >> q;
	
	const int MAX_MEMBER = 100000;

	// 各自の正解数を加算
	int correctCount[MAX_MEMBER] = {};
	for (int i = 0; i < q; i++)
	{
		int correcter;
		cin >> correcter;
		correctCount[correcter - 1] += 1;
	}

	// 減点の合計が持ち点を超えないか確認
	for (int i = 0; i < n; i++)
	{
		if (k > (q - correctCount[i]))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ulli unsigned long long int 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
/////////////////////////////////////////////////////////////////////
ulli fun(ulli a,ulli b)
{
	if((b-a)%2)
	{	
		return ((b-a-1)/2+1);		
	}
	return ((b-a)/2);
}

int main()
{
	ulli n,a,b;
	cin>>n>>a>>b;	
	if((b-a)%2)
	{	
		if(fun(a+(n-b),n)+n-b>=fun(1,b-a+1)+a-1)
			cout<<fun(1,b-a+1)+a-1;
		else cout<<fun(a+(n-b),n)+n-b;
	}
	else cout<<((b-a)/2);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589

signed main() {
    quickie
    int n ;
    cin >> n ;
    db g = 2*n*pi ;
    cout << fixed << setprecision(9) << g << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n, vector<int>(n));
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = 1;
		g[b][a] = 1;
	}
	vector<int> p(n-1);
	rep(i, n-1) p[i] = i+1;
	int ans = 0;
	do {
		bool ok = true;
		vector<int> now(n);
		rep(i, n-1) now[i+1] = p[i];
		rep(i, n-1) {
			if(g[now[i]][now[i+1]] == 0) ok = false;
		}
		if(ok) ans++;
	} while(next_permutation(all(p)));
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_zenkoku1_a() {
	ll N, A, B;

	cin >> N >> A >> B;

	ll max_val, min_val;

	max_val = min(A, B);
	min_val = max((A + B) - N, 0LL);

	cout << max_val << " " << min_val << "\n";
}

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

	solve_zenkoku1_a();

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    x = 3 * max([A, B, C]) - A - B - C
    print(x // 2 + x % 2 * 2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

// 再起でできる
int gcd2(int i, int j){
    if(j == 0){
        return i;
    }
    return gcd2(j, i%j);
}

int gcd3(int i, int j, int k){
    return gcd2(gcd2(i, j), k);
}

int main()
{    
    int K;
    cin >> K;
    
    long long cum = 0;
    for(int i=1; i<K+1; ++i){
        for(int j=1; j<K+1; ++j){
            for(int k=1; k<K+1; ++k){
                cum += gcd3(i, j, k);
            }   
        }
    }

    cout << cum << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//ori
#define MOD 1000000007
 
int main() {
  LL N, A, B, ans=0;
  cin >> N >> A >> B;
  VI d(N);
  REP(i,N) {
    cin >> d.at(i);
  }
  REP(i,N-1) {
    int x = d.at(i+1)-d.at(i);
    if (x*A < B) ans += x*A;
    else ans += B;
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
	double n;
	cin >> n;
	int odd = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			odd++;
		}
	}
	cout << odd / n << "\n";
	return 0;
}


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

int main()
{
  string S;
  cin >> S;
  bool A = false, B = false;
  for(int i = 0; i < 3; i++)
  {
    if(S.at(i) == 'A')
      A = true;
    else
      B = true;
  }
  if(A && B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
      
  

Measured memory_bytes: 256
from collections import deque

h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(h)]

yoko = [[0] * w for _ in range(h)]
#tate = [[0] * w for _ in range(h)]

q = deque([])
c = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1
        
        if s[i][j] == "#" or j == w-1:
            while len(q) > 0:
                x, y = q.pop()
                yoko[x][y] = c
            c = 0



m = 0

#print(yoko)

c = 0
for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1

        if s[i][j] == "#" or i == h-1:
            while len(q) > 0:
                x, y = q.pop()
                m = max(m, yoko[x][y] + c - 1)
            c = 0


print(m)


Measured memory_bytes: 265752
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
struct as
{
    int x,y;
}pos[10]; //用来存??次的起点和?点
struct node
{
    int x,y;
    int step;
};
bool vis[1010][1010];
char maze[1050][1050];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int H,W,N;

bool check(int x,int y)
{
    if (x<=0 || x>H) return 1;
    if (y<=0 || y>W) return 1;
    if (vis[x][y]) return 1;
    if (maze[x][y] =='X')return 1;
    return 0;
}
int bfs(int m,int n)
{
    memset(vis,0,sizeof vis);
    int sx = pos[m].x, sy = pos[m].y;
    int gx = pos[n].x, gy = pos[n].y;
   // printf("%d %d\n",sx,sy);
   // printf("%d %d\n",gx,gy);
    queue<node> Q;
    node a,next;
    a.step = 0;
    a.x = sx, a.y =sy;
    Q.push(a);
    while(!Q.empty())
    {
        a = Q.front();
        Q.pop();
        if (a.x == gx && a.y == gy)
            return a.step;
        for(int i = 0; i < 4 ;i++)
        {
            int nx = a.x + dx[i];
            int ny = a.y + dy[i];
            if(check(nx,ny))
                continue;
            else
            {
                vis[nx][ny] =1;
                next.x = nx,next.y = ny,next.step = a.step+1;
                Q.push(next);
            }
        }
    }
    return 999999;
}

int main()
{
   // freopen("in.txt","r",stdin);
    while(cin>>H>>W>>N)
    {
        int sx,sy;
        for(int i = 1;i<=H;i++)
        {
            for(int j = 1; j <= W;j++)
            {
                cin>>maze[i][j];
                if (maze[i][j] >='1' && maze[i][j]<='9')
                {
                    pos[maze[i][j]-'0'].x = i;
                    pos[maze[i][j]-'0'].y = j;
                }
                if (maze[i][j]=='S')
                    sx=i,sy = j;
            }
        }

        pos[0].x = sx,pos[0].y = sy;
        int ans = 0;
        for(int i = 0;i<N;i++)
            ans += bfs(i,i+1);
        cout<<ans<<endl;
    }
    return 0;
}

/*
入力例 2
4 5 2
.X..1
....X
.XX.S
.2.X.

出力例 2
12
*/

Measured memory_bytes: 3244
# -*- coding utf-8 -*-
N = int(input())
HN = [-1] + list(map(int, input().split())) + [10 ** 10]

for i in range(1, N + 1):
    if HN[i - 1] > HN[i]:
        print('No')
        exit()
    if HN[i - 1] < HN[i]:
        HN[i] = HN[i] - 1
print('Yes')

Measured memory_bytes: 14396