akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    ll n;
    cin >> n;
    string ans;
    while (n > 0){
        ans.push_back('a' + (n - 1) % 26);
        n = (n - 1) / 26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
def main():
    hugou_list = list(input())
    hugou_list = [s.replace('+', '1') for s in hugou_list]
    hugou_list = [s.replace('-', '-1') for s in hugou_list]
    hugou_list = [int(n) for n in hugou_list]
    print(sum(hugou_list))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

a, b = rl()

sa = str(a) * b
sb = str(b) * a
if sa > sb:
    print(sb)
else:
    print(sa)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;

void hehe()
{
    int n;
    cin >> n;
    if (n == 0)
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    cout << n;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        hehe();
    }

    return 0;
}


Measured memory_bytes: 3652
#include <set>
#include <iostream>

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

  std::set<int> s;
  for(int i = 0; i < n; ++i) {
    int d;
    std::cin >> d;
    s.insert(d);
  }

  std::cout << s.size() << std::endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
B = K
R = N-K
MOD = 10 ** 9 + 7
U = 10 * N + 100 # 適当
fact = [1] * (U+1)
fact_inv = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1] * n % MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD
    
def F(a,b):
    # a個のものを、すべての1個以上含むようなbグループに分ける
    # a-1 C b-1
    if a == 0 and b == 0:
      return 1
    if a < 1 or b < 1:
        return 0
    if b > a:
        return 0
    x = fact[a-1]
    x *= fact_inv[a-b]
    x *= fact_inv[b-1]
    x %= MOD
    return x

answer = []
for i in range(1,K+1):
    x = 0
    # RBRB, BRBR
    x += F(R,i) * F(B,i) * 2
    # RBRBR
    x += F(R,i+1) * F(B,i)
    # BRBRB
    x += F(R,i-1) * F(B,i)
    answer.append(x % MOD)

print(*answer, sep='\n')

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 3620
a,b,c = [x for x in input().split(" ")]

import math
a = float(a)
b = float(b)
c = int(c)
pi =math.pi
rad = c/360 * 2 * math.pi
S = a * b * math.sin(rad) * 0.5
L = a + b + (a*a + b * b - 2 * a * b * math.cos(rad))**(0.5)
h = b * math.sin(rad)
print("{:.9} {:.9} {:.9}".format(S,L,h))


Measured memory_bytes: 5736
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

LL Q, W, E, R, T, Y, U;

int main() {
	cin >> Q >> W >> E >> R >> T >> Y >> U;
	LL sum = 0;
	sum += W;
	sum += (Q - 1) / 2 * 2; Q -= (Q - 1) / 2 * 2;
	sum += (R - 1) / 2 * 2; R -= (R - 1) / 2 * 2;
	sum += (T - 1) / 2 * 2; T -= (T - 1) / 2 * 2;
	LL A[] = { Q,R,T };
	sort(A, A + 3);
	if (A[0] == 2) sum += 6;
	else if (A[1] == 2) sum += 4;
	else if (A[0] == 1) sum += 3;
	else if (A[2] == 2) sum += 2;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
def bubble_sort(a, n):
    sw_num = 0
    is_swapped = True
    i = 0
    while is_swapped:
        is_swapped = False
        for j in range(n-1, i, -1):
            if a[j] < a[j-1]:
                tmp = a[j]
                a[j] = a[j-1]
                a[j-1] = tmp
                is_swapped = True
                sw_num += 1
        i += 1

    return sw_num


n = int(input())
a = [int(i) for i in input().split()]

sw_num = bubble_sort(a, n)

print(' '.join([str(i) for i in a]))
print(sw_num)


Measured memory_bytes: 5608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	lint X, Y;
	cin >> X >> Y;

	if (abs(X - Y) <= 1) cout << "Brown";
	else cout << "Alice";
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N;
  scanf("%d", &N);
  std::map<int, int> mp;
  for (int i=2; i<=N; i++){
    int n=i;
    for (int j=2; j*j<=n; j++){
      while (n%j==0){
	mp[j]++;
	n=n/j;
      }
    }
    if (n!=1){
      mp[n]++;
    }
  }
  int over15=0, over25=0, over75=0, over5=0, over3=0;
  for (auto &entry: mp){
    if (entry.second>=4) {
      over5++;
    }
    if (entry.second>=2) {
      over3++;
    }
    if (entry.second>=14) {
      over15++;
    }
    if (entry.second>=24) {
      over25++;
    }
    if (entry.second>=74) {
      over75++;
    }
  }
  //printf("%d, %d\n", over5, over3);
  int ans =0;
  if (over5>=2 && over3>=3){
    ans += over5*(over5-1)/2*(over3-2);
  }
  if (over15>=1 && over5>=2){
    ans += over15*(over5-1);
  }
  if (over25>=1 && over3>=2){
    ans += over25*(over3-1);
  }
  if (over75>=1){
    ans += over75;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;

void solve() {
     string a,b,c;
     cin>>a>>b>>c;
     cout<<a[0]<<b[1]<<c[2];
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();

    //int t;cin>>t;while(t--)
        solve();
}

Measured memory_bytes: 3716
import sys
raw_input = sys.stdin.readline
range = xrange
a, b, c, x, y = map(int, raw_input().split())
if 2 * c >= a + b :
    print x * a + y * b
else:
    DP = [0]*(max(x, y)+1)
    for i in range(max(x, y)+1):
        DP[i] = 2 * c * i + a * max(0, x-i) + b * max(0, y-i)
    print min(DP)

Measured memory_bytes: 5764
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
using ll = long long;

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

int main()
{
    string s;
    string t;
    
    cin >> s;
    cin >> t;
    
    int ans = 0;
    
    rep (i,3){
        if (s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[505];
vector<int>ans; vector<P>vec; queue<int>Q;
vector<int>x[505];
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		 cin >> a[i];
		vec.pb(mp(a[i],i));
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++){
		for(int x=1;x<vec[i].sc;x++){
			Q.push(vec[i].sc);
		}
	}
	int nxt = 0;
	for(int i=0;i<n*n;i++){
		if(nxt < n && i+1 == vec[nxt].fi){
			ans.pb(vec[nxt].sc);
			for(int j=0;j<n-vec[nxt].sc;j++){
				Q.push(vec[nxt].sc);
			}
			nxt++;
		}
		else{
			if(Q.empty()){
				puts("No"); return 0;
			}
			ans.pb(Q.front()); Q.pop();
		}
	}
	for(int i=0;i<n*n;i++){
		x[ans[i]].pb(i+1);
	}
	for(int i=1;i<=n;i++){
		if(a[i] != x[i][i-1]){
			puts("No"); return 0;
		}
	}
	puts("Yes");
	for(int i=0;i<n*n;i++) printf("%d%c",ans[i],(i==n*n-1?'\n':' '));
}

Measured memory_bytes: 3188
#include<algorithm>//STL通用算法
 
#include<bitset>//STL位集容器
 
//#include<bits/stdc++.h>//编译器GCC 4.8支持的万能头文件，基本包含所有头文件
 
#include<cctype>//C字符处理
 
#include<cerrno>//C的错误报告机制
 
#include<clocale>
 
#include<cmath>//兼容C语言数学库
 
#include<complex>//复数类
 
#include<cstdio>//C语言输入输出工具
 
#include<cstdlib>//C语言通用工具
 
#include<cstring>//C字符串
 
#include<ctime>
 
#include<deque>//STL双端队列容器
 
#include<exception>//异常处理类
 
#include<fstream>//文件输入输出流
 
#include<functional>//STL定义运算函数（代替运算符）
 
#include<limits>
 
#include<list>//STL线性列表容器
 
#include<map>//STL映射容器
 
#include<iomanip>
 
#include<ios>//基本输入/输出支持
 
#include<iosfwd>//输入/输出系统使用的前置声明
 
#include<iostream>//基本输入输出流
 
#include<queue>//STL队列容器
 
#include<set>//STL集合容器
 
#include<sstream>//基于字符串的流
 
#include<stack>//STL堆栈容器
 
#include<stdexcept>//标准异常类
 
#include<streambuf>//底层输入/输出支持
 
#include<string>//字符串类
 
#include<utility>//STL通用模板类
 
#include<vector>//STL动态数组容器
 
#include<cwchar>
 
#include<cwctype>
using namespace std;
int n,a,pan[110],ans;
int main(){
	scanf("%d %d",&n,&a);
	for(int i=1,x;i<=a;i++) {
		scanf("%d",&x);
		for(int j=1,y;j<=x;j++) {
			scanf("%d",&y);
			pan[y]=1;
		}
	}
	for(int i=1;i<=n;i++)
	    if(!pan[i])
	        ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 3824
#include <stdio.h>

int main(){
  int x[3];
  scanf("%d %d %d",&x[0],&x[1],&x[2]);
  if(x[0]==x[1]){
    printf("%d",x[2]);
  }else if(x[0]==x[2]){
    printf("%d",x[1]);
  }else{
    printf("%d",x[0]);
  }
  return 0;
}

Measured memory_bytes: 128
import collections
import heapq
import copy
n,m,p = map(int,raw_input().split(' '))

adj = collections.defaultdict(list)
def f(e,p):
	u,v,w = e
	return (u,v,p-w)

edges = [f(map(int, raw_input().split()), p) for _ in range(m) ]

fa = collections.defaultdict(list)
ba = collections.defaultdict(list)
for u,v,_ in edges:
	fa[u].append(v)
	ba[v].append(u)
def dfs(u,adj,vis):
	stack = collections.deque([u])
	while(stack):
		uu = stack.pop()
		vis.add(uu)

		for v in adj[uu]:
			if v not in vis:
				vis.add(v)
				stack.append(v)
va = set([1])
dfs(1, fa, va)

vb = set([n])
dfs(n, ba, vb)

h = {u: (+float('inf') if u > 1 else 0) for u in range(1, n + 1)}

for _ in range(n-1):
	for u,v,w in edges: h[v] = min(h[v], h[u] + w)

fnc = False
for u,v,w in edges: 
	if v in va and v in vb and h[v] > h[u] + w:
		fnc = True
		break
print max(0,-h[n]) if (not(fnc) and h[n] != +float('inf')) else -1 

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

int main(){
  int x,y; cin>>x>>y;
  int ans=0;
  if(x==1)ans+=300000;
  if(x==2)ans+=200000;
  if(x==3)ans+=100000;
  if(y==1)ans+=300000;
  if(y==2)ans+=200000;
  if(y==3)ans+=100000;
  if(x==1 && y==1)ans+=400000;

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int h, w, a, b;
    cin>>h>>w>>a>>b;
    rep(i, h) {
        rep(j, w) {
            if (i < b) {
                if (j < a) cout<<1;
                else cout<<0;
            }
            else {
                if (j < a) cout<<0;
                else cout<<1;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
<?php
fscanf(STDIN, "%d%f", $a, $b);
$b=(int)round($b*100);
echo intdiv($a*$b,100);

function str(){return trim(fgets(STDIN));}
function ints($n = false){
  if($n===false){
    return array_map('intval',explode(' ',trim(fgets(STDIN))));
  }else{$ret = [];for($i = 0; $i < $n; $i++)foreach(array_map('intval',explode(' ',trim(fgets(STDIN)))) as $j => $v)$ret[$j][] = $v;return $ret;}
}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      if($both == 0){
        $G[$a][] = $b;
      }elseif($both == 1){
        $G[$a][] = $b;
        $G[$b][] = $a;
      }else{
        $G[$b][] = $a;
      }
    }else{
      list($a, $b, $d) = $values;
      if($both == 0){
        $G[$a][] = [$b, $d];
      }elseif($both == 1){
        $G[$a][] = [$b, $d];
        $G[$b][] = [$a, $d];
      }else{
        $G[$b][] = [$a, $d];
      }
    }
  }
  return $G;
}


Measured memory_bytes: 16124
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
string s;
bool u[30];
int main(){
	string stupid="zyxwvutsrqponmlkjihgfedcba";
	cin>>s;
	if(s==stupid)
	{
		cout<<-1;
		return 0;
	}
	if(s.size()==26)
	{
		char ch[26];
		for(int i=0;i<26;i++)
			ch[i]=s[i];
		next_permutation(ch,ch+26);
		for(int i=0;i<26;i++)
		{
			if(ch[i]>s[i])
			{
				cout<<ch[i];
				return 0;
			}
			cout<<ch[i];
		}
	}
	else
	{
		for(int i=0;i<s.size();i++)
			u[s[i]-'a']=true;
		for(int i=0;i<26;i++)
			if(!u[i])
			{
				cout<<s<<char(i+'a');
				return 0;
			}
	}
	return 0;
}

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

int main() {
    int d[4][3][10] = { 0 };
    int n, b, f, r, v;
 
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b >> f >> r >> v;
        d[b-1][f-1][r-1] += v;
    }
    for (int i=0; i<4; i++) {
        for (int j=0; j<3; j++) {
            for (int k=0; k<10; k++)
            	cout << " " << d[i][j][k];
            cout << endl;
        }
        if(i != 3)
        cout << "####################" << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
use std::io;

fn main () {
    let mut s = String::new();
    let stdin = io::stdin();

    stdin.read_line(&mut s).unwrap();

    let n = s.trim().parse().unwrap_or(0);

    s.clear();

    stdin.read_line(&mut s).unwrap();

    let answer =
        s.trim().split(' ').take(n)
        .map(|x| x.parse().unwrap_or(0u64).trailing_zeros())
        .min().unwrap_or(0);

    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
  string keyWord;
  string input;
  int count = 0;
  cin >> keyWord;
  while(true){
    cin >> input;
    if(input == "END_OF_TEXT") break;
    transform(input.begin(), input.end(), input.begin(), ::tolower);
    if(input == keyWord){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}



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

int main() {
  int x,y;
  cin >> x >> y;
  int a,b,c,d,e;
  int count=0;
  for (int i=x; i<y+1; i++) {
    a = i/10000;
    b = (i-a*10000) / 1000;
    c = (i-a*10000-b*1000) / 100;
    d = (i-a*10000-b*1000-c*100) /10;
    e = i-a*10000-b*1000-c*100-d*10;
    
    int i_inv;
    i_inv = e*10000 + d*1000 + c*100 + b*10 + a;
    if (i==i_inv) {
      count++;
    }
  }
  cout << count << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define ll long long int
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
map<int,int>cnt;
set<int>nums;
vi pom;
int32_t main()
{
  BOOST;
	int n,k;
	cin>>n>>k;
	int ans=0;
	for (int i=1;i<=n;i++){
		int a;
		cin>>a;
		cnt[a]++;
		nums.insert(a);
	}
	
	for (auto it:nums){
		pom.pb(cnt[it]);
	}
	sort(pom.begin(),pom.end());
	reverse(pom.begin(),pom.end());
	while (sz(pom)>k)ans+=pom.back(),pom.pop_back();
	cout<<ans;
  return 0;
}


Measured memory_bytes: 27124
#include<stdio.h>
int main(){
  int n,c,M=1e9+7,i,d;
  long long s=1;
  scanf("%d",&n);
  for(i=c=0;i<n;i++){
    scanf("%d",&d);
    c++;
    if(d<c*2-1){
      s=(s*c)%M;
      c--;
    }
  }
  for(;c;c--)s=(s*c)%M;
  printf("%lld\n",s);
  return 0;
}


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


def solve(S: str, T: str):
    ans = T + S
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
a = [0]*n
a = list(map(int, input().split()))

a.sort()
i = 0
tmp = 0
while i + 1 < n and a[i+1] < 0:
      a[i] *= -1
      a[i+1] *= -1
      i += 2

a.sort()
if a[1] < -a[0]:
    a[1] *= -1
    a[0] *= -1


sum = 0
for i in range(n):
      sum += a[i]
print(sum)

Measured memory_bytes: 15020
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int M, K;
  cin >> M >> K;
  int64_t N = 1;
  N <<= M;
  if((M==1&&K==1)||K >= N){
  	cout << -1 << endl;
  	return 0;
  }
  if(M==1&&K==0){
  	cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
  	cout << endl;
  	return 0;
  }
  cout << K << " ";
  for(int64_t i = N - 1; i >= 0; --i)
 		if(i != K)cout << i << " ";
  cout << K << " ";
 	for(int64_t i = 0; i < N; ++i)
 		if(i != K)cout << i << " ";
  cout << endl;
}


Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}

import           Control.Monad.Trans.State.Strict
import qualified Data.ByteString.Char8            as B
import           Data.Char
import           Data.Coerce
import qualified Data.List                        as L

main :: IO ()
main = do
    [_, m] <- map read.words <$> getLine
    xyzs <- L.unfoldr (runParser parseInt3) <$> B.getContents
    print $ solve m xyzs

solve :: Int -> [(Int, Int, Int)] -> Int
solve m xyzs = maximum [sum . take m . L.sortBy (flip compare) $ map (priority sign) xyzs|sign<-signs]
  where
    signs = (,,) <$> [-1, 1] <*> [-1, 1] <*> [-1, 1]
    priority (x0,y0,z0) (x1,y1,z1) = x0*x1+y0*y1+z0*z1

type Parser a = StateT B.ByteString Maybe a

runParser :: Parser a -> B.ByteString -> Maybe (a, B.ByteString)
runParser = runStateT

parseInt :: Parser Int
parseInt = coerce $ B.readInt . B.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = (,) <$> parseInt <*> parseInt

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = (,,) <$> parseInt <*> parseInt <*> parseInt


Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    string S;
    cin>>S;
    int N=S.size();
    int count=0;
    //cout<<N;
    rep(i, (N+1)/2){
        if(S[i]!=S[N-i-1]) count++;
    }
    cout<<count<<endl;
    return 0;
}

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

int main(){
  int x;
  cin >> x;
  int c500;
  int c5;
  
  c500 = ceil(x/500);
  x = x%500;
  c5 = ceil(x/5);
  x = x%5;
  
  cout << c500*1000 + c5*5 << endl;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    cin >> s;
    int a, z;
    for(a = 0; a < s.size() && s[a] != 'A'; a++);
    for(z = s.size()-1; z >= 0 && s[z] != 'Z'; z--);
    cout << (z - a + 1) << endl;

}


Measured memory_bytes: 640
program prob2
    implicit none
    integer::N, ans, i, j, ansi
    integer, allocatable::a(:)
    read(*,*) N
    allocate(a(N))
    read(*,*) a
    ans = dot_product(a,a)
    do i = -100, 100
        ansi = 0
        do j = 1, N
            ansi = ansi + (a(j) - i)**2
        end do
        if(ansi < ans) then
            ans = ansi
        end if
    end do
    write(*,*) ans

    deallocate(a)
    stop
end program prob2

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        String answer = "Yes";
        for (int i = 1; i <= len; i++) {
            char c = s.charAt(i - 1);
            // 偶数文字目
            if ((i % 2) == 0) {
                if ((c == 'L') || (c == 'U') || (c == 'D')) {
                    continue;
                } else {
                    answer = "No";
                    break;
                }
            }
            // 奇数文字目
            else {
                if ((c == 'R') || (c == 'U') || (c == 'D')) {
                    continue;
                } else {
                    answer = "No";
                    break;
                }
            }
        }
        System.out.println(answer);
        sc.close();
    }
}

Measured memory_bytes: 35608
#include <iostream>
#include <locale>

int main() {
  std::locale l = std::locale::classic();

  int N, K;

  std::cin >> N >> K;

  for (int i=0; i<N; i++) {
    char c;
    std::cin >> c;

    if (i==K-1) {
      std::cout << std::tolower(c, l);
    } else {
      std::cout << c;
    }
  }

  std::cout << std::endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

//-----------------------------------------

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

  int n;
  cin >> n;
  vll fib(100);
  fib[0] = 1;
  fib[1] = 1;
  for(int i=2;i<=n;i++){
    fib[i] = fib[i-1] + fib[i-2];
  }
  cout << fib[n] <<endl;




  return 0;
}




Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  long long N, px = 0, py = 0;
  cin >> N;
  long long pt = 0, x, y, t;
  bool flag = true;
  for(int i = 0; i < N; i++){
    cin >> t >> x >> y;
    long long dx = abs(px - x);
    long long dy = abs(py - y);
    long long nt = t - pt;
    long long d = dx + dy;
    if(d > nt || ((nt-d) % 2 != 0)){
      flag = false;
      break;
    }
    px = x;
    py = y;
    pt = t;
  }
  if(flag == true)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
int main()
{
    Imposter
    
    ll k;
    cin>>k;
    ll p=0;
    for(int i=0;i<1e7;i++)
    {
        p=p*10+7;
        p=p%k;
        if(p==0)
        {
            cout<<i+1;
            goto end;
        }
    }
    cout<<-1;
    end:
    ;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int answer;
  for(int i = 1;i < 10 ^ 3;i++) {
    if(i * i <= N) {
      answer = i * i;
    }
    else {
      break;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
words = lambda t : list(map(t, input().split()))
a,b = words(int)

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

def lcm(x,y):
    return (x * y) // gcd(x,y)

print(lcm(a,b))


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

int main() {
    //縦横の入力
    int H, W;
    cin >> H >> W;
    //二次配列作成
    vector<vector<char>> date(H, vector<char> (W));
    //初期値をfalse(bool値の為、charの初期値に出来ない為ここで書く)
    vector<bool> tate(H, false);
    vector<bool> yoko(W, false);
    //dateの入力
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> date.at(i).at(j);
        }
    }
    //date(i,j)が＃なら真に
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (date.at(i).at(j) == '#') {
                tate.at(i) = true;
                yoko.at(j) = true;
            }
        }
    }
    //もしある縦(i)が真で、その配列(横)(j)も真なら
    for (int i = 0; i < H; i++) {
        if (tate.at(i)) {
            for (int j = 0; j < W; j++) {
                if (yoko.at(j)) {
                    cout << date.at(i).at(j);
                }
            }
            cout << endl;
        }
    }

}

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

using namespace std;

long long gcd(long long a, long ,long b){
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a,b) ) * b;
}

int main(void){
    int n;
    cin >> n;
    
    vector<long long> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    
    long long ans = t[0];
    for (int i = 0; i < n; i++) ans = lcm(ans,t[i]);
    cout << ans << endl;
}


Measured memory_bytes: 3616
/*input
10 4
40 10 20 70 80 10 20 70 80 60
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int a[n+1];
	rep(i, n) cin >> a[i+1];
	int dp[n+1];
	dp[0]=0;a[0]=a[1];
	repl(i, 1, n+1) {
		dp[i]=INF;
		repl(j, 1, k+1) {
			if(i-j>=0) dp[i]=min(dp[i], dp[i-j]+abs(a[i-j]-a[i]));
		}
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 4392
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,cos,radians,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
v=sorted(lis)
u=sorted(lis)[-1]
dis=[]
if u%2==0:
    k=u//2
    for i in range(n-1):
        dis.append(abs(v[i]-k))
    l=sorted(dis)[0]
    for i in range(n-1):
        if dis[i]==l:
            print(u,v[i])
            sys.exit()
else:
    k=(u-1)//2
    m=(u+1)//2
    for i in range(n-1):
        dis.append(abs(v[i]-k))
        dis.append(abs(v[i]-m))
    l=sorted(dis)[0]
    #print(l)
    for i in range(len(dis)):
        if l==dis[i]:
            print(u,v[i//2])
            sys.exit()

Measured memory_bytes: 65708
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
    if A[i] == B[i]:
        if A[i] == C[i]:
            count += 0
        else:
            count += 1
    else:
        if A[i] == C[i]:
            count += 1
        elif B[i] == C[i]:
            count += 1
        else:
            count += 2

print(count)

Measured memory_bytes: 3064
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var [n,m,c]=arr.shift().split(" ").map(Number);
var L=arr.shift().split(" ").map(Number);
var cw = arr.map(v => v.split(" ").map(Number));
cw.sort(function(a,b){
   return b[1] - a[1];
});
var sum=0;
for(var i=0;i<cw.length;i++){
   if(m==0)break;
   var max = L[cw[i][0]-1];
   if(max>0){
      sum+=cw[i][1];
      L[cw[i][0]-1]--;
      m--;
   }
}
console.log(sum);


Measured memory_bytes: 51744
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll K;
  cin >> K;
  vector<string> targets;
  for (int i = 0; i < 10; i++) {
    targets.push_back(to_string(i));
  }
  vector<vector<string> > memo(10);
  memo[0] = targets;
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (auto element : memo[i - 1]) {
        if (abs(j - (element[0] - '0')) < 2) {
          char new_j = j + '0';
          memo[i].push_back(new_j + element);
          if (j != 0) targets.push_back(new_j + element);
          // cout << new_j + element << endl;
        }
      }
    }
  }
  cout << targets[K] << endl;
  return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
typedef vector<long long int> vl;
#define pb push_back
#define mp make_pair

ll expm(ll x, ll y, ll mod){
	ll ans = 1;
	while(y>0){
		if(y%2==1) ans*=x, ans%=mod, y--;
		else x*=x, x%=mod, y/=2;
	}
	return ans%mod;
}

ll exp(ll x, ll y){
	return expm(x,y,LLONG_MAX);
}

void shift(vector<long long int>& dp1, vector<long long int>& dp2){
	for(int i = 0; i < dp2.size(); i++) {
		dp2[i] = dp1[i];
	}
}

long long int findMaxValue(long long int n, long long int w, vector<long long int>& weights, vector<long long int>& value) {
	// dp[w][n] -> best value we can get, if we have w capacity remaining and n objects remaining
	// dp[w][n] = max(dp[w - weigths[n]][n-1] + value[n], dp[w][n-1])
	vector<long long int> dp1(w+1, 0), dp2(w+1,0);
	for(long long int i = 0; i < n; i++){
		for(long long int capacity = 1; capacity <= w; capacity++) {
			long long int val_leaving_current = dp1[capacity];
			long long int val_taking_current = 0;
			if(weights[i] <= capacity) 
				val_taking_current = dp1[capacity - weights[i]] + value[i];

			dp2[capacity] = max(val_taking_current, val_leaving_current);
		}

		shift(dp2, dp1); //copies dp2 to dp1
		// for(long long int i=0;i<=w;i++) cout << dp1[i] << " ";
		// cout << endl;
	}

	return dp1[w];
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	int n, w;
	cin >> n >> w;
	vector<long long int> weights(n), value(n);
	for(int i = 0; i < n; i++) {
		cin >> weights[i] >> value[i];
	}

	cout << findMaxValue(n, w, weights, value) << endl;
	return 0;
}



Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950


bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss>b.ss;
    return (a.ff < b.ff); 
} 
void solve(){


    char ch;
    cin>>ch;

    // ll num =ch-'0';
    // cout<<num<<endl;
    // if(num>=97){
    //     cout<<'a';
    // }
    // else{
    //     cout<<'A';
    // }

    if(ch>='a') cout<<'a';
    else cout<<'A';

    return;    
} 
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3636
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


namespace atPra
{
    class Class1
    {
        static void Main()
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var D = int.Parse(Console.ReadLine());

            int AB;
            if (A >= B) AB = B;
            else AB = A;

            int CD;
            if (C >= D) CD = D;
            else CD = C;

            Console.WriteLine(AB + CD);

        }
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/04  Problem: 075_arc_c / Link: https://arc075.contest.atcoder.jp/tasks/arc075_c?lang=en ----- */
/* ------問題------

長さ N の整数列 a= {a1,a2,…,aN} と、整数 K が与えられます。
a の空でない連続する部分列 {al,al+1,…,ar} (1≤l≤r≤N) は N(N+1)⁄2 個存在します。これらのうち、算術平均が K 以上であるものは何個あるでしょうか？

-----問題ここまで----- */
/* -----解説等-----

平衝二分木がほしいときはBITでだいたいできる

----解説ここまで---- */
template<typename type>
struct BIT { // 1-index
	int N;
	int nn;
	vector<type> data;
	BIT(int n) {
		N = n + 1;
		data = vector<type>(n + 1, 0);
		nn = 1;
		while (nn * 2 <= N)nn *= 2;
	}
	void add(int i, type w) { // a[i] += w
		for (int x = i; x <= N; x += x & -x) {
			data[x] += w;
		}
	}
	type sum(int i) { // iまでの和 [1,i]
		type ret = 0;
		for (int x = i; x > 0; x -= x & -x) {
			ret += data[x];
		}
		return ret;
	}
	// [l, r]
	type sum(int l, int r) {
		if (l > r) return 0;
		return sum(r) - sum(l - 1);
	}
};



LL N, K;

LL ans = 0LL;

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

	cin >> N >> K;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
		a[i] -= K;
	}
	VL sum(N + 1, 0);
	FOR(i, 0, N) {
		sum[i + 1] = sum[i] + a[i];
	}

	VL xs;
	FOR(i, 0, N) {
		xs.push_back(sum[i + 1]);
	}
	SORT(xs);
	UNIQ(xs);
	BIT<LL> bit(N + 10);
	FOR(i, 0, N + 1) {
		int id = lower_bound(ALL(xs), sum[i]) - xs.begin();
		ans += bit.sum(id + 1);
		bit.add(id + 1, 1);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6640
n = int(input())
a = list(map(int, input().split()))

w = []
num = 0
for i in a:
    if 1 <= i <= 399:
        if 1 not in w:
            w.append(1)
    elif 400 <= i <= 799:
        if 400 not in w:
            w.append(400)
    elif 800 <= i <= 1199:
        if 800 not in w:
            w.append(800)
    elif 1200 <= i <= 1599:
        if 1200 not in w:
            w.append(1200)
    elif 1600 <= i <= 1999:
        if 1600 not in w:
            w.append(1600)
    elif 2000 <= i <= 2399:
        if 2000 not in w:
            w.append(2000)
    elif 2400 <= i <= 2799:
        if 2400 not in w:
            w.append(2400)
    elif 2800 <= i <= 3199:
        if 2800 not in w:
            w.append(2800)
    else:
        num += 1
if 0 < len(w):
    print(len(w), len(w)+num)
else:
    print(1, len(w)+num)

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

using namespace std;

struct Edge {
	int to, cap, rev;
};

bool used[2000];
vector< vector<Edge> > G;

#define INF 1e9

void addEdge(int from, int to, int cap) {
	G[from].push_back({to, cap, (int)G[to].size()});
	G[to].push_back({from, cap, (int)G[from].size()-1});
}
int dfs(int s, int t, int f) {
	if (s == t) return f;
	used[s] = true;

	for (int i = 0; i < G[s].size(); ++i) {
		Edge& e = G[s][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int flow(int s, int t) {
	int flow = 0;
	while (1) {
		memset(used, false, sizeof(used));
		int f = dfs(s, t, INF);
		if (f == 0) break;
		else flow += f;
	}
	return flow;
}

int main() {
	int H, W, C, M, Nw, Nc, Nm;
	while (cin >> H >> W >> C >> M >> Nw >> Nc >> Nm, H >= 0) {
		int s = H+2*(W+C+M), t = s+1;
		int w = t+1, c = w+2, m = c+2;
		G.clear(); G.resize(m+1);

		addEdge(w, w+1, Nw);
		addEdge(c, c+1, Nc);
		addEdge(m, t, Nm);
		for (int i = 0; i < H; ++i) {
			addEdge(s, i, 1);
			addEdge(i, w, 1);
		}
		for (int i = 0; i < W; ++i) {
			int n; cin >> n;
			for (int j = 0; j < n; ++j) {
				int id; cin >> id; --id;
				addEdge(id, H+i, 1);
			}
			addEdge(H+i, H+W+i, 1);
			addEdge(H+W+i, c, 1);
		}
		for (int i = 0; i < C; ++i) {
			int n; cin >> n;
			for (int j = 0; j < n; ++j) {
				int id; cin >> id; --id;
				addEdge(H+W+id, H+2*W+i, 1);
			}
			addEdge(w+1, H+W+i, 1);
			addEdge(H+2*W+i, H+2*W+C+i, 1);
			addEdge(H+2*W+C+i, m, 1);
		}
		for (int i = 0; i < M; ++i) {
			int n; cin >> n;
			for (int j = 0; j < n; ++j) {
				int id; cin >> id; --id;
				addEdge(H+2*W+C+id, H+2*W+2*C+i, 1);
			}
			addEdge(c+1, H+2*W+C+i, 1);
			addEdge(H+2*W+2*C+i, t, 1);
		}
		cout << flow(s, t) << endl;
	}
}

Measured memory_bytes: 1492
#include<stdio.h>

void infoReset();

int info[4][3][10];

int main(void){
	int n,i,j,k,b,f,r,v;
	
	scanf("%d",&n);
	
	infoReset();
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		
		b--;
		f--;
		r--;
		info[b][f][r] += v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",info[i][j][k]);	
			}
			printf("\n");
		}
		if(i==3) break;
		printf("####################\n");
	}
}

void infoReset(){
	int i,j,k;

	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				info[i][j][k] = 0;
			}
		}
	}
}


Measured memory_bytes: 2048