akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {

  int N , M ;
  int ans = 0 ;
  cin >> N >> M ;
  if (N == M ) cout << "Yes" <<endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a) a.begin(), a.rbegin()
using namespace std;
int main(){
int N, M;cin >> N;
map<string, int> P;

for(int i = 0; i < N; i++){
string S;
cin >> S;
P[S]++;
}

cin >> M;

for(int i = 0; i < M; i++){
string S;
cin >> S;
P[S]--;
}
int Ans = 0;
for(auto i = P.begin(); i != P.end(); i++){
if(Ans < i->second) Ans = i->second;
}
 cout << Ans << endl;
}

Measured memory_bytes: 256
import sys
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()
if sum(a)<=k:
  print(0)
  sys.exit()
pointer=0
l=0
r=0
for i in range(n):
  r=max(r,a[i]*f[i])
while l+1<r:
  try1=(r+l)//2
  required=0
  for i in range(n):
    required+=(max(0,a[i]-try1//f[i]))
  if required>k:
    l=try1
  else:
    r=try1
required=0
for i in range(n):
  required+=(max(0,a[i]-l//f[i]))
if required>k:
  print(r)
else:
  print(l)

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

#define pb push_back
#define SZ(x) ((int)x.size())

const int N = 2010;

int vis[N], ok[N][N], in[N], a[N];
vector<int> g[N];
int n;

void dfs(int rt) {
  vis[rt] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i] && ok[rt][i]) {
      in[i]++;
      g[rt].pb(i);
      dfs(i);
    }
}

void Top() {
  priority_queue<int> q;
  for (int i = 1; i <= n; i++)
    if (!in[i]) q.push(i);
  while (!q.empty()) {
    int now = q.top();
    q.pop();
    cout << a[now] << " ";
    for (int i = 0; i < SZ(g[now]); i++) q.push(g[now][i]);
  }
}

signed main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (__gcd(a[i], a[j]) != 1) ok[i][j] = ok[j][i] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  Top();
  return 0;
}


Measured memory_bytes: 16256
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)

for i in range(1, N+1):
    t[i], x[i], y[i] = map(int,input().split())

for i in range(1, N+1):
    if t[i]-t[i-1] < abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]):
        print('No')
        exit()
    elif t[i] % 2 != (x[i] + y[i]) % 2:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 11636
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, k;
    cin>>n>>k;
    cout<<n-k+1<<endl;

    return 0;
}


Measured memory_bytes: 256
#82
#ALDS1_3_A
st=[]
for i in input().split():
    if i in '+-*':
        v2 = st.pop()
        v1 = st.pop()
        st.append(str(eval(v1 + i + v2)))
    else:
        st.append(i)
print(st[0])


Measured memory_bytes: 5572
#include<stdio.h>


int main(void){
    char S[100],T[100];

    scanf("%s %s", &S, &T);
    int i=0;

    while(T[i]!='\0'){
        printf("%c", T[i]);
        i++;
    }
    i=0;
    while(S[i]!='\0'){
        printf("%c", S[i]);
        i++;
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())

a = list(map(int, input().split()))

total = sum(a)
x = 0
ans = float("inf")
for i in range(n-1):
  x += a[i]
  y = total - x
  if(abs(x-y) < ans):
    ans = abs(x-y)
    
print(ans)

Measured memory_bytes: 24832
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

K,S = map(int,input().split())
cnt = 0

for x in range(K+1):
    for y in range(K+1):
        z =S - x - y
        if z <=K and z>=0:
            cnt +=1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(void) {

    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a == b && b == c) {
        printf("1\n");
    }
    else if (a == b || b == c || a == c) {
        printf("2\n");
    }
    else {
        printf("3\n");
    }

    return 0;
}

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

using namespace std;

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

	for (int i = 0; i < 4; i++) {
		cout << s[i];
	}
	cout << " ";
	for (int i = 4; i < 12; i++) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
char a[4][4];
int i,j;
for (i=1;i<=3;i++)
for (j=1;j<=3;j++)
cin>>a[i][j];

cout<<a[1][1]<<a[2][2]<<a[3][3];
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();

    println!("{}", (n - 1) / 2 + 1);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void) {
    char s[10]={ };
    int i, n, x=753, t[10]={ }, test;
    while((s[i]=getchar())!='\n') {
        t[i]=s[i]-'0';
        i++;
    }
    n=i;
    for(i=0; i+2<n; i++) {
        test=753-(t[i]*100+t[i+1]*10+t[i+2]);
        if(test<0)
            test*=-1;
        if(test<x)
            x=test;
    }
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: String -> String -> Bool
calc [] [] = False
calc _ [] = False
calc [] _ = True
calc (s : ss) (t : ts)
  | s == t = calc ss ts
  | sc > tc = False
  | sc < tc = True
  where
    sc = ord s
    tc = ord t

main = do
  [s] <- getString
  [t] <- getString
  let s' = sort s
  let t' = reverse (sort t)
  let tf = calc s' t'
  if tf then putStrLn "Yes" else putStrLn "No"


Measured memory_bytes: 3804
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
 
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    double a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double x,y;
    y=((e-a)*(a*a+b*b-c*c-d*d)-(c-a)*(a*a+b*b-e*e-f*f))/(2*(e-a)*(b-d)-2*(c-a)*(b-f));
    if(c-a!=0){
         x=(2*(b-d)*y-a*a-b*b+c*c+d*d)/(2*(c-a));
    }else{
        x=(2*(b-f)*y-a*a-b*b+e*e+f*f)/(2*(e-a));
    }
    double r=sqrt(pow(x-a,2)+pow(y-b,2));
    printf("%.3f %.3f %.3f\n",x,y,r);
    }
     
     
    return 0;
}


Measured memory_bytes: 3208
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#include <tuple>
#define INF 1000000000000
const long long MOD = 998244353;

using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

string num2string(llong num){
    ostringstream oss;
    oss << num;
    return oss.str();
}

int main(){
    llong H,W;
    cin >> H >> W;
    vector<vector<string> > Map(H, vector<string>(W));
    string ans="";
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> Map[i][j];
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(Map[i][j]=="snuke"){
                ans += 'A'+(char)j;
                ans += num2string(i+1);
                cout << ans << endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3232
import math

in_str = input()

in_arr = in_str.split()

A = int(in_arr[0])
B = int(in_arr[1])
H = int(in_arr[2])
M = int(in_arr[3])

AM = 60 * H + M

X = math.sqrt(A*A + B*B - 2 * A * B * math.cos((math.pi * 11 * AM)/360))

print(X)

Measured memory_bytes: 9412
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;


void solve(){
	ll n; cin>>n;
	vector<ll> A, B, C;
	rep(i,n+1){
		ll a; cin>>a;
		A.PB(a);
	}
	rep(i,n){
		ll b; cin>>b;
		B.PB(b); C.PB(0);
	}
	B.PB(0); C.PB(0);

	ll ans = 0;
	rep(i,n){
		if((B[i]+C[i])>=A[i]){
			ans += A[i];
			if((C[i]-A[i])>=0){
				C[i+1] = B[i];
			}else{
				C[i+1] = B[i]+C[i]-A[i];
			}
			if(i==n-1){
				ans += min(A[n], B[n]+C[n]);
			}
		}else{
			ans += B[i] + C[i];
		}
		// cout << B[i+1] SP ans << endl;
	}
	cout << ans << endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

#define MAX 100003

class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor,[0,sz_-1]で定義
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> X(N,0);
    vector<ll> Y(N,0);
    UnionFind tree(2*MAX);
    for(ll i=0;i<N;++i){cin>>X[i]>>Y[i];tree.unite(X[i],Y[i]+MAX);}
    Map mx,my;
    for(ll i=0;i<MAX;++i)mx[tree.root(i)]++;
    for(ll i=MAX;i<2*MAX;++i)my[tree.root(i)]++;
    ll rec=0;
    for(ll i=0;i<2*MAX;++i)rec+=mx[i]*my[i];
    prt(rec-N)


    return 0;
}


Measured memory_bytes: 29952
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e18
#define max_n 200002
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

/*

const int _N = 1234567;

ll F[_N];
ll IF[_N];

void init() {
	F[0] = 1;
	for(int i=1; i<_N; i++) F[i] = mul(F[i-1], i);
	IF[_N-1] = power(F[_N-1], mod-2);
	for(int i=_N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll ncr(ll x, ll y) {
	if(y > x || y < 0) return 0;
	return mul(F[x], mul(IF[x-y], IF[y]));
}

/**/

class mxLazySegTree {
public:
	int sz;
	vector <ll> tree, lazy;
	mxLazySegTree(int _sz) {
		sz = _sz;
		tree.assign(sz*4, 0);
		lazy.assign(sz*4, 0);
	}
	// update
	void update(int p, int L, int R, int l, int r, ll val) {
		if(lazy[p] != 0) {
			tree[p] += lazy[p];
			if(L != R) {
				lazy[2*p] += lazy[p];
				lazy[2*p+1] += lazy[p];
			}
			lazy[p] = 0;
		}
		if(R < l || r < L) return; // R < L
		if(l <= L && R <= r) {
			tree[p] += val;
			if(L != R) {
				lazy[2*p] += val;
				lazy[2*p+1] += val;
			}
			return;
		}
		int M = (L+R)/2;
		update(2*p, L, M, l, r, val);
		update(2*p+1, M+1, R, l, r, val);
		tree[p] = max(tree[2*p], tree[2*p+1]);
	}
	void update(int l, int r, ll val) {
		update(1, 0, sz-1, l, r, val);
	}
	// query
	ll query(int p, int L, int R, int l, int r) {
		if(R < l || r < L) return -1e18; // L > R
		if(lazy[p] != 0) {
			tree[p] += lazy[p];
			if(L != R) {
				lazy[2*p] += lazy[p];
				lazy[2*p+1] += lazy[p];
			}
			lazy[p] = 0;
		}
		if(l <= L && R <= r) return tree[p];
		int M = (L+R)/2;
		return max(query(2*p, L, M, l, r), query(2*p+1, M+1, R, l, r));
	}
	ll query(int l, int r) {
		return query(1, 0, sz-1, l, r);
	}
};

int n, m;
ll a[max_n];
int l[max_n], r[max_n];
vector <int> s[max_n];
vector <int> e[max_n];

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		cin >> l[i] >> r[i] >> a[i];
		s[l[i]].pb(i);
		e[r[i]].pb(i);
	}
	ll res = 0, ans;
	mxLazySegTree st(n+1);
	for(int i=1; i<=n; i++) {
		for(int id : s[i]) st.update(0, i-1, a[id]);
		ans = st.query(0, i-1);
		res = max(res, ans);
		st.update(i, i, ans);
		for(int id : e[i]) st.update(0, l[id]-1, -a[id]);
	}
	cout << res << endl;
	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

Measured memory_bytes: 37760
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let mut s: std::collections::VecDeque<char> = sc.chars().iter().map(|&c|c).collect();
    let mut rev = false;

    let q: usize = sc.cin();
    for _ in 0..q {
        let t: usize = sc.cin();
        if t == 1 {
            rev ^= true;
        } else {
            let f: usize = sc.cin();
            let c: char = sc.cin::<String>().chars().next().unwrap();
            if f == 1 && !rev || f ==2 && rev {
                s.push_front(c);
            } else {
                s.push_back(c);
            }
        }
    }

    let mut cs: Vec<char> = s.iter().map(|&c| c).collect();
    if rev {
        cs.reverse();
    }
    for &c in cs.iter() {
        print!("{}", c);
    }
    println!("");
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 6652
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	double a,z;
	int s,d[9],f[5],g,h,i,j,x;
	while(1){
		scanf("%lf",&a);
		s=a;
		if(s==-1) break;
		z=a-s;
		x=0;
		for(i=0;i<4;i++){
			f[i]=0;
			if(1<=z*2) f[i]=1;
			z=z*2;
			if(f[i]==1) z-=1;
			if(z==0) x=1;
		}
		g=256;
		h=0;
		if(x==0) printf("NA\n");
		else{
			for(i=7;i>=0;i--){
				d[i]=0;
				if(g<s&&h==0) g/=2;
				else{
					h=1;
					if(s%2==1) d[i]=1;
					s/=2;
				}
			}
		for(i=0;i<8;i++) printf("%d",d[i]);
		printf(".");
		for(i=0;i<4;i++) printf("%d",f[i]);
		printf("\n");
		}
	}
	return 0;
}

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

set<ll> pf(ll x) {
  set<ll> res;
  for (ll i = 2; i * i <= x; ++i) {
    int n = 0;
    while (x % i == 0)
      x /= i, ++n;
    if (n > 0)
      res.insert(i);
  }
  if (x > 1)
    res.insert(x);
  return res;
}

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

  auto sa = pf(a);
  auto sb = pf(b);

  int ans = 1;
  for (auto& p : sb)
    if (sa.find(p) != sa.end())
      ++ans;

  cout << ans << endl;
}

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

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

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

    sort(A, A + N, greater<>());

    if (A[M - 1] >= (double)total / (4 * M)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using ll = long long;
int dy[24]={-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2},dx[24]={-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2},n,m,sy,sx,ey,ex,gx[4]={0,-1,0,1},gy[4]={1,0,-1,0};
char _map[1010][1010];
priority_queue<int, vector<int>, greater<int>> pq[1010][1010];
struct pos{
    int y,x,cnt;
    bool operator < (const pos &a) const{
        return cnt > a.cnt;
    }
};
priority_queue<pos> q;
bool in(int a,int b){return 1<=a && a<=n && 1<=b && b<=m;}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m>>sy>>sx>>ey>>ex;
    for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) cin>>_map[i][j];
    pq[sy][sx].push(0);
    q.push({sy,sx,0});
    while(q.size()){
        auto[y,x,cnt] = q.top();
        q.pop();
        if(pq[y][x].top() < cnt) continue;
        if(y == ey && x == ex){
            cout<<cnt;
            return 0;
        }
        for(int i=0; i<4; i++){
            int ny = y + gy[i], nx = x + gx[i];
            if(!in(ny,nx) || _map[ny][nx] == '#') continue;
            if(pq[ny][nx].empty()){
                pq[ny][nx].push(cnt);
                q.push({ny,nx,cnt});
            }
            else if(pq[ny][nx].top() > cnt){
                pq[ny][nx].pop();
                pq[ny][nx].push(cnt);
                q.push({ny,nx,cnt});
            }
        }
        for(int i=0; i<24; i++){
            int ny = y + dy[i], nx = x + dx[i];
            if(!in(ny,nx) || _map[ny][nx] == '#') continue;
            if(pq[ny][nx].empty()){
                pq[ny][nx].push(cnt + 1);
                q.push({ny,nx,cnt+1});
            }
            else if(pq[ny][nx].top() > cnt){
                pq[ny][nx].pop();
                pq[ny][nx].push(cnt + 1);
                q.push({ny,nx,cnt+1});
            }
        }
    }
    cout<<-1;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	map<int, int> deg;
	for(int i=0; i<n; i++){
		int d = graph[i].size();
		if(d%2){
			cout << "No" << endl;
			return 0;
		}
		deg[d]++;
	}

	dbg(deg[2], deg[4], deg[6]);

	if(deg[2]==n||deg[2]==n-1&&deg[4]==1){
		cout << "No" << endl;
		return 0;
	}
	if(deg[2]+deg[4]<n||deg[4]>2) {
		cout << "Yes" << endl;
		return 0;
	}

	int x=-1, y=-1;
	for(int i=0; i<n; i++){
		if(graph[i].size()==4){
			if(x<0) x=i;
			else y=i;
		}
	}

	vector<bool> visit(n);
	queue<int> que;
	que.push(x);
	int n_path = 0;
	while(!que.empty()){
		int v = que.front();
		que.pop();
		if(visit[v]) continue;
		visit[v] = true;
		for(int u:graph[v]){
			if(u==y){
				n_path++;
			} else if(u!=x&&!visit[u]){
				que.push(u);
			}
		}
	}

	if(n_path==2){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 5760
s = list(input())
s2 = []
for i in range(len(s)):
    s2.append(s[i])
s3 = list(set(s2))
s3.sort()
s4 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if s3 == s4:
    print('None')
else:
    for i in range(int(len(s3))):
        if s3[i] != s4[i]:
            print(s4[i])
            break
        if i == len(s3)-1:
            print(s4[i+1])

Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 100005
int freq[mex];

signed main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
    	int x; cin>>x;
    	freq[x]++;
    	ans+=x;
    } 
    int q; cin>>q;
    while(q--){
    	int b,c; cin>>b>>c;
    	ans-=freq[b]*b;
    	ans+=freq[b]*c;
    	freq[c]+=freq[b];
    	freq[b]=0;
    	cout<<ans<<endl;
    }

}

Measured memory_bytes: 4336
//Suplex
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
long long f[10000];

struct leo{
	int h,p;
}a[10000];

bool cmp(leo a,leo b)
{
	return a.h+a.p<b.h+b.p;
}

inline long long min(long long a,long long b)
{
	return a<b ? a : b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].h,&a[i].p);
	sort(a+1,a+1+n,cmp);
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=i;j;j--)
			if(f[j-1]<=a[i].h) f[j]=min(f[j],f[j-1]+a[i].p);
	for(int i=n;i;i--) if(f[i]<1e18){printf("%d\n",i);break;}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  vector<long> v(n);
  rep(i,n) cin>>v[i];

  sort(all(v));

  if(n%2==1){
    vector<long> x;
    rep(i,n) if(i != n/2) x.pb(abs(v[i] - v[n/2]));
    sort(all(x));
    long ans = x[0];
    rep(i,1,n-1) ans += x[i]*2;
    cout << ans << endl;
  } else {
    long ans = 0;
    rep(_,2){
      long tmp = 0;
      rep(i,n/2) tmp += v[n/2] - v[i];
      tmp*=2;
      tmp -= v[n/2] - v[n/2 - 1];
      rep(i, n/2+1, n) tmp += 2*(v[i] - v[n/2]);
      ans = max(ans, tmp);

      reverse(all(v));
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int H, W;
char P[100][100];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &H, &W), cin.get();
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) P[i][j] = cin.get();
		cin.get();
	}
	for(int i = 0; i < W + 2; i++) printf("#");
	printf("\n");
	for(int i = 0; i < H; i++){
		printf("#");
		for(int j = 0; j < W; j++) printf("%c", P[i][j]);
		printf("#\n");
	}
	for(int i = 0; i < W + 2; i++) printf("#");
	printf("\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	for (int j = 0; j < n; ++j) {
		cout << (j == 0 ? "" : " ") << v[j];
	}cout << endl;
	for (int i = 1; i <n; ++i) {
		int k = v[i];
		int j = i - 1;
		while (j >= 0 && v[j] > k) {
			v[j + 1] = v[j];
			j--;
		}
		v[j + 1] = k;
		for (int j = 0; j < n; ++j) {
			cout << (j == 0 ?"" : " ") << v[j];
		}cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int main() {
	int n, m, x;
	while (cin >> n >> m&&(n != 0||m!=0)) {
		multiset<int>a;
		a.insert(0);
		for (int i = 0; i < n; i++) {
			cin >> x;
			a.insert(x);
		}
		for (int j = 0; j < m; j++) {
			cin >> x;
			a.insert(x);
		}
		multiset<int>::iterator it = a.begin();
		it++;
		int sa = 0;
		for (int i = 1; i <= n + m; i++) {
			sa = max(sa, (*it) - (*--it));
			it++;
			it++;
		}
		cout << sa << endl;
	}
}

Measured memory_bytes: 4044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int pay = 700;
		if (s.charAt(0) == 'o') {
			pay += 100;
		}
		if (s.charAt(1) == 'o') {
			pay += 100;
		}
		if (s.charAt(2) == 'o') {
			pay += 100;
		}
		
		System.out.println(pay);
		scanner.close();

	}

}


Measured memory_bytes: 21844
import bisect

inf = 10**18

a,b,q = map(int,input().split())
s = [-inf]+[int(input()) for _ in range(a)]+[inf]
t = [-inf]+[int(input()) for _ in range(b)]+[inf]
x = [int(input()) for _ in range(q)]

for i in x:
    a1 = s[bisect.bisect_right(s,i)]
    b1 = t[bisect.bisect_right(t,i)]
    a2 = s[bisect.bisect_right(s,i)-1]
    b2 = t[bisect.bisect_right(t,i)-1]
    ans = inf
    for j in [a1,a2]:
        for k in [b1,b2]:
            ans = min(ans,abs(i-j)+abs(j-k),abs(i-k)+abs(k-j))
    print(ans)

Measured memory_bytes: 16144
package main

import "fmt"

func main() {
	var s string
	var ans int
	fmt.Scan(&s)
	for _, opr := range s {
		// From rune to string
		if string(opr) == "+" {
			ans++
		// From runt to string
		} else if string(opr) == "-" {
			ans--
		}
	}
	fmt.Println(ans)
}

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

int main() {
	ll n; cin >> n;
	vector<ll> a(n);

	bool dp[1000001];
	memset(dp, 0, sizeof(dp));
	map<ll, ll> mp;

	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}

	sort(all(a));

	ll ans = 0;
	rep(i, n) {
		if (dp[a[i]]) {
			continue;
		}
		if (mp[a[i]] == 1) {
			ans++;
		}

		ll num = a[i];
		while (num <= 1000000) {
			dp[num] = true;
			num += a[i];
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 18148
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	ll k;
	cin>>k;
	int n=50;
	vector<ll> v;
	for(int i=0;i<n;i++){
		v.pb(i);
	}
	for(int i=0;i<n;i++){
		v[i] += k/50 ;
	}
	for(int i=0;i<(k%50);i++){
		v[i] += 50;
		for(int j=0;j<n;j++){
			if(i!=j)v[j]--;
		}
	}
	cout<<50<<endl;
	for(int i=0;i<n;i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll h,w,d; cin>>h>>w>>d;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;

  
  ll a[h][w];
  vector<pair<ll,ll>> b(h*w+1);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> a[i][j];
      b[a[i][j]]=MP(i,j);
    }
  }
  vector<ll> c(h*w+1);
  for(i=d+1;i<=h*w;i++){
    c[i]=c[i-d]+abs(b[i-d].first-b[i].first)+
         abs(b[i-d].second-b[i].second); 
  }
  ll q;
  cin >> q;
  vector<ll> l(q),r(q);
  for(i=0;i<q;i++) cin>>l[i]>>r[i];
  for(i=0;i<q;i++){
    cout<<c[r[i]]-c[l[i]]<<endl;
  }

  return 0;
}

Measured memory_bytes: 5504
h, w, d = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

B = [0]*(h*w)

C = [0]*(h*w)

for i in range(h):
    for j in range(w):
        a = A[i][j]
        B[a-1] = (j+1, i+1)

for i in range(h*w):
    if i-d >= 0:
        j = i-d
        px, py = B[j]
        x, y = B[i]
        C[i] = abs(x-px)+abs(y-py)+C[j]
    else:
        C[i] = 0
#print(C)

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    l, r = l-1, r-1
    print(C[r]-C[l])


Measured memory_bytes: 57948
#include <iostream>
#include <algorithm>
using namespace std;
int n; long long x, sum[64][64], dp[64][64][2];
int main() {
	dp[0][0][0] = 1;
	for (int i = 0; i < 60; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i + 1][j][0] += dp[i][j][0] + dp[i][j][1];
			dp[i + 1][j + 1][1] += dp[i][j][0] + dp[i][j][1];
		}
		for (int j = 0; j <= i + 1; j++) sum[i + 1][j + 1] = dp[i + 1][j][0] + dp[i + 1][j][1];
		for (int j = 1; j <= i + 2; j++) sum[i + 1][j] += sum[i + 1][j - 1];
	}
	while (cin >> n >> x, x) {
		int cnt = lower_bound(sum[n], sum[n] + n + 1, x) - sum[n] - 1;
		x -= sum[n][cnt] + 1;
		for (int i = n; i >= 1; i--) {
			for (int j = 0; j <= 1; j++) {
				if (x - dp[i][cnt][j] >= 0) {
					x -= dp[i][cnt][j];
				}
				else {
					cout << j;
					cnt -= j;
					break;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = input()
l = len(N)
K = int(input())

dpSt = makelist(l, K+1)
dpCa = makelist(l, K+1)

init = int(N[0])
dpSt[0][1] = 1
dpCa[0][0] = 1
dpCa[0][1] = init - 1

for i in range(1, l):
    now = int(N[i])

    if now == 0:
        for k in range(K+1):
            dpSt[i][k] = dpSt[i-1][k]
            dpCa[i][k] = dpCa[i-1][k]
        for k in range(1, K+1):
            dpCa[i][k] += dpCa[i-1][k-1] * 9
    else:
        for k in range(1, K+1):
            dpSt[i][k] = dpSt[i-1][k-1]

        for k in range(K+1):
            dpCa[i][k] += dpSt[i-1][k]
        for k in range(1, K+1):
            dpCa[i][k] += dpSt[i-1][k-1] * max(0, now-1)


        for k in range(K+1):
            dpCa[i][k] += dpCa[i-1][k]
        for k in range(1, K+1):
            dpCa[i][k] += dpCa[i-1][k-1] * 9

ans = dpSt[l-1][K] + dpCa[l-1][K]
print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
    #pragma gcc optimize("ofast")
    using namespace std;

    #define ll long long
    #define ull unsigned long long
    #define ui unsigned int
    #define mod 1000000007
    #define us unsigned short
    #define IOS ios_base::sync_with_stdio(0);
    #define INF LONG_MAX
    #define PI 3.1415926535897932384626
    #define mp make_pair
    #define fi first
    #define se second
    #define pb push_back
    #define rep(x,j,n)for(int x=j;x<n;x++)
    typedef vector<pair<ll,ll>> vpi;
    typedef vector<ll> vi;
    typedef vector<vi> vvi;

    ll modexp(ll a,ll b,ll m)
    {
    	ll r=1;
    	a=a%m;
    	while(b>0)
    	{
    	if(b&1)
    		r=(r*a)%m;
    	b=b/2;
    	a=(a*a)%m;
    	}
    	return r%m;
    }


    int main()
    {
        IOS
        ll n;
        cin>>n;
        vi b(n-1);
        rep(i,0,n-1)
            cin>>b[i];
        ll maxi=-INF;
        ll sum=0;
        //cout<<sum<<" \n";
        vi a(n,0);
        a[0]=b[0];
        a[1]=b[0];
        ll p_a=1;

        for(ll i=1;i<n-1;i++)
        {
            if(b[i]>=a[p_a])
                {
                    a[p_a+1]=b[i];
                    p_a++;
                }
            else
                {
                    a[p_a]=b[i];
                    a[p_a+1]=b[i];
                    p_a++;
                }
        }
        rep(i,0,n){
           // cout<<a[i]<<' ';
            sum+=a[i];
        }

        cout<<sum<<'\n';
        return 0;
    }


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
 
        int matrix[][]=new int[n][m];
        for(int i=0;i<=n-1;i++){
            for(int j=0;j<=m-1;j++){
                matrix[i][j]=sc.nextInt();
            }
        }
        int vector[]=new int[m];
        for(int k=0;k<=m-1;k++){
            vector[k]=sc.nextInt();
        }
        for(int i=0;i<=n-1;i++){
            int ans=0;
            for(int j=0;j<=m-1;j++){
                ans+=matrix[i][j]*vector[j];
            }
            System.out.println(ans);
        }
    }
}



Measured memory_bytes: 41036
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
#include <limits>
#include <numeric>
#include <type_traits>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int N,W;
int w[MAX],v[MAX];
ll dp[104][MAX];//dp[i][j]:=i-1番目の品物までで重さの合計がjになる最大の価値
int main(){
    cin>>N>>W;
    rep(i,N)cin>>w[i]>>v[i];
    memset(dp,0,sizeof(dp));
    rep(i,N)rep(j,W+1){
        if(j>=w[i])
        dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
        else dp[i+1][j]=dp[i][j];
    }
    cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 82176
#include <iostream>

typedef long long ll;
using namespace std;

ll modpow(ll a, ll b, ll m) {
  if (b==0) return 1;
  ll tmp = modpow(a*a%m,b/2,m);
  if (b&1) tmp = tmp*a%m;
  return tmp;
}

ll mperm(ll a, ll b, ll m) {
  if (a < b) {
    return 0;
  }
  ll ret=1;
  while(b--) {
    ret = (ret*(a--)) % m;
  }
  return ret;
}

ll pminv(ll a, ll p) {
  return modpow(a,p-2,p);
}

ll mcomb(ll a, ll b, ll m) {
  return (mperm(a,b,m)*pminv(mperm(b,b,m),m))%m;
}

int main() {
  ll n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<mcomb(k,n,mod)<<endl;
  return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int D[7][7]={{},
{0,0,4,2,5,3,0},
{0,3,0,6,1,0,4},
{0,5,1,0,0,6,2},
{0,2,6,0,0,1,5},
{0,4,0,1,6,0,3},
{0,0,3,5,2,4,0}},G[7],N,i,t,f;
int sc(int d)
{
    int i;
    for(i=1;i<=6;i++)
        if(G[i]==d)
            return i;
}
int main()
{
    for(i=1;i<7;i++)scanf("%d",G+i);
    scanf("%d",&N);
    for(;N--;)
    {
        scanf("%d%d",&t,&f);
        printf("%d\n",G[D[sc(f)][sc(t)]]);
    }
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0) return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int k; cin >> k;
	string s; cin >> s;
	if(s.length() > k) s = s.substr(0, k) + "...";
	cout << s << endl;
}


Measured memory_bytes: 3636
//#STAY_HOME
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N;
  in(N);
  string S;
  in(S);
  map<char,ull>cnt;
  rep(i,N)cnt[S[i]]++;
  ull ans=cnt['R']*cnt['G']*cnt['B'];
  rep(i,N){
    up(len,1,N){
      ull a=i;
      ull b=a+len;
      ull c=b+len;
      if(c<N){
        if(S[a]!=S[b]&&S[a]!=S[c]&&S[b]!=S[c])ans--;
      }
    }
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n, b;
  cin >> n;
  int c[n][2];
  int pq[n][n][1];
  int ans[n][n];
  b = n;
  for(int i=0; i<n; i++){
     for(int j=0; j<2; j++){
		cin >> c[i][j];
  	 }
   }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      ans[i][j]=n;
      if(i!=j){
          pq[i][j][0]=c[i][0]-c[j][0];
          pq[i][j][1]=c[i][1]-c[j][1];
      }  
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(i!=j){
        for(int k=0; k<n; k++){
          for(int l=0; l<n; l++){
            if(k!=l){
            if(((c[k][0]-c[l][0])==pq[i][j][0])&&((c[k][1]-c[l][1])==pq[i][j][1])) ans[i][j]=ans[i][j]-1;
            }
          }
        }
      }
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
        if(b>ans[i][j]) b=ans[i][j];
    }
  }
  cout << b;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    }
}

Measured memory_bytes: 22996
use std::cmp::{max, min};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let xy = (0..n)
        .map(|_| (sc.read::<i64>(), sc.read::<i64>()))
        .collect::<Vec<_>>();
    let mut r_max = 0;
    let mut r_min = 1 << 50;
    let mut b_max = 0;
    let mut b_min = 1 << 50;
    for &(x, y) in xy.iter() {
        let (r, b) = if x < y { (x, y) } else { (y, x) };
        r_max = max(r, r_max);
        r_min = min(r, r_min);
        b_max = max(b, b_max);
        b_min = min(b, b_min);
    }

    let ans = (r_max - r_min) * (b_max - b_min);
    let mut xy = xy
        .into_iter()
        .map(|(x, y)| (min(x, y), max(x, y)))
        .collect::<Vec<_>>();
    xy.sort();

    let mut cur_max = xy.iter().map(|t| t.0).max().unwrap();
    let mut ans1 = cur_max - xy.iter().map(|t| t.0).min().unwrap();
    let mut store_min = 1 << 50;
    for i in 0..(n - 1) {
        cur_max = max(cur_max, xy[i].1);
        store_min = min(store_min, xy[i].1);
        let cur_min = min(xy[i + 1].0, store_min);
        ans1 = min(ans1, cur_max - cur_min);
    }

    let min0 = xy.iter().map(|t| t.0).min().unwrap();
    let max1 = xy.iter().map(|t| t.1).max().unwrap();
    let ans2 = ans1 * (max1 - min0);
    println!("{}", min(ans, ans2));
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;
long long const LL_INF = 5000000000000000000LL;
long long const MODULE = 1000000007LL;

long long x[MAX_N], y[MAX_N];

void calc_every(int n, int m, long long* x) {
	for (int i = 0; i < n; i++) x[i] = 0;
	for (int dd = 0; dd < n; dd++) {
		long long cnt = n - dd;
		if (dd == 0)
			x[dd] = (cnt * ( (m*(m-1LL)/2) % MODULE )) % MODULE;
		else
			x[dd] = (((cnt * m) % MODULE) * m) % MODULE;
	}
	for (int dd = 0; dd < n; dd++) x[dd] = (x[dd] * ((long long)dd)) % MODULE;
}

long long inv[MAX_N], fakt[MAX_N], rev_fakt[MAX_N];

long long mulmod(long long a, long long b) {
	return ((a % MODULE)* (b % MODULE)) % MODULE;
}

long long cnk(long long n, long long k) {
	if (k > n) return 0;
	if (k <= 0) return 1;
	return ((fakt[n] * rev_fakt[n - k]) % MODULE* rev_fakt[k]) % MODULE;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	long long n, m, k;
	cin >> n >> m >> k;

	calc_every(n, m, x);
	calc_every(m, n, y);

	inv[1] = 1;
	for (int i = 2; i <= n*m; i++) inv[i] = mulmod(inv[MODULE % i], (MODULE - MODULE / i));
	fakt[0] = 1; fakt[1] = 1;
	rev_fakt[0] = 1; rev_fakt[1] = 1;
	for (int i = 2; i <= n*m; i++) {
		fakt[i] = mulmod(fakt[i - 1], i);
		rev_fakt[i] = mulmod(rev_fakt[i - 1], inv[i]);
	}

	long long dg_2 = cnk(n * m - 2, k - 2);

	long long ans = 0;
	for (int i = 0; i < n; i++)
		ans = (ans + (x[i] * dg_2)) % MODULE;
	for (int i = 0; i < m; i++)
		ans = (ans + (y[i] * dg_2)) % MODULE;
	cout << ((ans % MODULE + MODULE) % MODULE);
	return 0;
}


Measured memory_bytes: 9984