akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 11415141919810;
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;
}
ll dp[110][100010];
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n, w;
    cin >> n >> w;
    vector<ll> W(n), V(n);
    for (ll i = 0; i < n; i++)
        cin >> W[i] >> V[i];
        for(ll i = 0; i < 110; i++){
            for(ll j = 0; j < 100010; j++){
                dp[i][j] = INF;
            }
        }
        dp[0][0] = 0;
        for (ll i = 1; i <= n; i++)
    {
        for (ll j = 0; j < 100010; j++)
        {
            if (j - V[i - 1] >= 0)
                chmin(dp[i][j], dp[i - 1][j - V[i - 1]] + W[i - 1]);
            chmin(dp[i][j], dp[i - 1][j]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i < 100010; i++)
    {   
        if(dp[n][i] <= w)
        ans = i;
    }
    cout << ans << endl;
}

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

bool flg = true;
ll cnt = 0, bcnt = 0;

string s;
int main()
{
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'W')
        {
            cnt += bcnt;
        }
        else
        {
            bcnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3736
n=int(input())
ans=n
for i in range(n+1):
  cc=0
  t=i
  while t>0:
    cc=cc+t%6
    t=t//6
  t=n-i
  while t>0:
    cc=cc+t%9
    t=t//9
  if ans>cc:
    ans=cc
print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n, l;
  cin >> n >> l;
  vector<int> a(n + 1);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = l + i - 1;
    sum += a[i];
  }
  vector<int> res;
  for (int u = 1; u <= n; u++) {
    int t = 0;
    for (int i = 1; i <= n; i++) {
      if (i == u) continue;
      t += a[i];
    }
    res.push_back(t);
  }
  int dif = 1 << 30;
  int ans = 0;
  for (int x : res) {
    if (abs(x - sum) < dif) {
      ans = x;
      dif = abs(x - sum);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        k: usize,
        candles: [isize; n],
    }

    let mut min = isize::max_value();

    for i in 0..n-k+1 {
        let l = i + k - 1;
        min = cmp::min(cmp::min(candles[i].abs()+(candles[l]-candles[i]).abs(), candles[l].abs()+(candles[i]-candles[l]).abs()), min);
    }

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll dp[401][401];
ll sum[401][401];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	ll ar[n];
    	for(int i=0;i<n;i++)
    		cin>>ar[i];
    	for(int l = n; l > 0; l--)
    	{
    		for(int r = l; r <= n; r++)
    		{
    			ll mm = 1e18;
    			if(l==r)
    			{
    				sum[l][r] = ar[l-1];
    				continue;
    			}
    			sum[l][r] = sum[l][r-1] + ar[r-1];
    			for(int k = l; k < r; k++)
    			{
    				ll ans = (dp[l][k] + dp[k+1][r] + sum[l][k] + sum[k+1][r]);
    				mm = min(mm,ans);
    			}
    			dp[l][r] = mm;
    		}
    	}
    	cout<<dp[1][n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
let main () =
  let n,a,b = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c) in
  let rec func acc n = if n = 0 then acc else func (acc + (n mod 10)) (n / 10) in
  let res = ref 0 in
  for i = 1 to n do
    let s = func 0 i in
    if a <= s && s <= b then res := !res + i;
  done;
  Printf.printf "%d\n" !res

let _ = main ()


Measured memory_bytes: 384
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, y = MI()
    for i in range(n+1):
        for j in range(n-i+1):
            k = n - i - j
            if 10000*i + 5000*j + 1000*k == y:
                print("{} {} {}".format(i, j, k))
                sys.exit()
    print("-1 -1 -1")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9092
//
//  abc065d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/11/09.
//

#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>

#define MAX 100005

using namespace std;

typedef long long ll;

struct Path
{
    int from,to,cost;
    
    bool operator<(const Path& rhs)const
    {
        return cost<rhs.cost;
    }
};

struct UF
{
    vector<int> par;
    
    UF(int n):par(n)
    {
        for(int i=0;i<n;i++) par[i]=i;
    }
    
    int root(int x)
    {
        if(par[x]==x) return x;
        else          return par[x]=root(par[x]);
    }
    
    void unite(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        par[rx]=ry;
    }
    
    bool same(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        return rx==ry;
    }
};

struct V
{
    int pos,index;
    bool operator<(const V& rhs)const
    {
        return pos<rhs.pos;
    }
};

int main()
{
    int n;
    cin>>n;
    vector<Path> p;
    int x[MAX],y[MAX];
    V vx[MAX],vy[MAX];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        vx[i]={x[i],i};
        vy[i]={y[i],i};
    }
    sort(vx,vx+n);
    sort(vy,vy+n);
    for(int i=0;i<n-1;i++)
    {
        p.push_back({vx[i].index,vx[i+1].index,vx[i+1].pos-vx[i].pos});
        p.push_back({vy[i].index,vy[i+1].index,vy[i+1].pos-vy[i].pos});
    }
    sort(p.begin(),p.end());
    UF uf(n);
    
    ll ans=0;
    for(int i=0;i<p.size();i++)
    {
        int from=p[i].from;
        int to=p[i].to;
        int cost=p[i].cost;
        
        if(!uf.same(from,to))
        {
            uf.unite(from,to);
            ans+=cost;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch SyntheticKadomatsu | diff SyntheticKadomatsu.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address SyntheticKadomatsu.cpp && ./a.out

/*
 
 3/11/2019
 
 14:37-
 
 */

const int MAX_N=10+1;
LL L[MAX_N];
LL T[3];
int N;

void solve() {
  const LL Inf=1e10;
  LL res=Inf;
  REP(mmask,1<<(2*N)) {
    int mask=mmask;
    LL cost=0;
    vector<LL> X[3];
    REP(i,N) {
      int a=mask%4; mask/=4;
      if(a<3)X[a].push_back(L[i]);
    }
    REP(i,3) {
      LL x=max(0,SZ(X[i])-1)*10;
      x+=abs(accumulate(ALL(X[i]),0LL)-T[i]);
      cost+=x;
      if(X[i].empty()) cost=Inf;
    }
    SMIN(res,cost);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>T[0]>>T[1]>>T[2];
  REP(i,N) cin>>L[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int city,day,i,j;
    cin>>city>>day;
    int chart[city+1][day+1];
    int distance[city],weather[day];
    for(i=0;i<city;i++)
    cin>>distance[i];
    for(i=0;i<day;i++){
        cin>>weather[i];
        chart[0][i]=0;
    }
    for(i=1;i<city+1;i++){
        for(j=0;j<day+1;j++){
             if(j==i){
                chart[i][j]=chart[i-1][j-1]+distance[i-1]*weather[j-1];
                continue;
            }
            else if(j>i){
                 int a = chart[i-1][j-1]+distance[i-1]*weather[j-1];
                 if(chart[i][j-1]<a)
                 chart[i][j]=chart[i][j-1];
                 else
                 chart[i][j]=a;
            }
            
        }
    }
    cout<<chart[city][day]<<endl;
}



Measured memory_bytes: 6240
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    rep(i,n){
        ll a,b;
        cin >> a >>b;
        v[i].second = a-b;
        v[i].first  = a+b;
    }
    sort(v.begin(),v.end());
    ll res = 0;
    ll pos = -INF;
    rep(i,n){
        if(pos <= v[i].second){
            res++;
            pos = v[i].first;
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 4756
#include <stdio.h>
#include <string.h>

int main(){
   int i,j,n;
   char s[100];

   scanf("%s",s);
   n=strlen(s);
   for (i=0,j=n-1;i<j;i++,j--)
      if (s[i]!=s[j]) break;
   if (i<j) {
      puts("No");
      return 0;
   }
   for (i=0,j=(n-3)/2;i<j;i++,j--)
      if (s[i]!=s[j]) break;
   if (i<j) {
      puts("No");
      return 0;
   }
   for (i=(n+1)/2,j=n-1;i<j;i++,j--)
      if (s[i]!=s[j]) break;
   if (i<j) puts("No");
   else     puts("Yes");
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 200001
#define M 21
vector<int> ex[N], ey[N];
void init(int n, vector<int>* e) {
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d%d", &u, &v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
}
int fx[N], fy[N][M], dx[N], dy[N];
void dfsx(int u) {
    for (auto v : ex[u]) {
        if (v == fx[u]) continue;
        fx[v] = u, dx[v] = dx[u] + 1;
        dfsx(v);
    }
}
void dfsy(int u) {
    for (auto v : ey[u]) {
        if (v == fy[u][0]) continue;
        fy[v][0] = u, dy[v] = dy[u] + 1;
        for (int i = 1; i < M; i++) fy[v][i] = fy[fy[v][i - 1]][i - 1];
        dfsy(v);
    }
}
int lca(int u, int v) {
    if (dy[u] < dy[v]) swap(u, v);
    for (int i = M - 1; ~i; i--)
        if (dy[fy[u][i]] >= dy[v]) u = fy[u][i];
    if (u == v) return u;
    for (int i = M - 1; ~i; i--)
        if (fy[u][i] != fy[v][i]) u = fy[u][i], v = fy[v][i];
    return fy[u][0];
}
int main() {
    int n, addx, addy;
    scanf("%d%d%d", &n, &addx, &addy);
    init(n, ex);
    init(n, ey);
    dfsx(addx);
    dfsy(addy);
    queue<int> que;
    que.push(addx);
    int ans = 0;
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        if (dx[u] >= dy[u]) continue;
        if (~ans) ans = max(ans, dy[u] << 1);
        for (auto v : ex[u]) {
            if (v == fx[u]) continue;
            if (dy[v] + dy[u] - 2 * dy[lca(u, v)] > 2) ans = -1;
            que.push(v);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 49404
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

int dp[5005][5005];
int main(){
	int n,d;
	cin>>n>>d;
	if(n%(d*2+1)==0) cout<<n/(d*2+1)<<endl;
	else cout<<n/(d*2+1)+1<<endl;
}

Measured memory_bytes: 256
//ABC042B

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,l;
    vector<string> v;
    cin>>n>>l;

    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());

    for(int i=0;i<v.size();i++){
        cout<<v[i];
    }

    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
bool PS(char x, char y) {
if((x=='0') &&(y !='0')) {
  return true;
}
  else if ((x=='0') &&(y=='0')) {
    return false;
  }
  else if ((x=='1') &&(y<'3')) {
    return true;
  }
  else if (x>'1') {
    return false;
  }
  else if ((x=='1') &&(y>'2')) {
    return false;
  }
}
int main() {
 string S;
  cin >>S;
  bool a=PS(S.at(0),S.at(1));
  bool b=PS(S.at(2), S.at(3));
  if((a) &&(b)) {
    cout <<"AMBIGUOUS"<< endl;
  }
else if ((a) &&(!b)) {
  cout <<"MMYY"<< endl;
}
else if ((b) &&(!a)) {
  cout <<"YYMM"<< endl;
}
else if ((!b) &&(!a)) {
  cout <<"NA"<< endl;
}
}
  


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int H,A,i;

    scanf("%d%d",&H,&A);

    i=0;
    while(1)
    {
        H=H-A;
         i++;

        if(H<=0)
        {
            break;
        }
    
    }

printf("%d",i);

}


Measured memory_bytes: 128
#ifdef DEBUG
#include "../../lib/utils.cpp"
#endif
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
#define int int64_t
#define INF 10e9

/* ==== declarations ====== */
// functions
void solve();
void getInput();

// global variables
int N, K;
int maxsize = 0;
vector<int> A;

void getInput()
{
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        int inp;
        cin >> inp;
        A.push_back(inp);
        maxsize = max(maxsize, inp);
    }
}

bool isOK(double u)
{
    if (u == 0) return false;
    int cost = 0;
    for (auto a : A)
    {
        if (a <= u)
        {
            continue;
        }

        int c = floor(a / u);
        if (c * u == a)
        {
            c = c - 1;
        }
        // print("cost, c:", cost, c);

        cost += c;
    }
    return cost <= K;
}

void solve()
{
    // print(A);
    // print(isOK(3));
    // exit(0);

    double left = 0;
    double right = maxsize + 1;
    while (right - left > 0.01)
    {
        // print("===");
        // print(right, left);
        // print("===");
        double mid = left + (right - left) / 2;
        if (isOK(mid))
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    int test = floor(right);
    if (isOK(test))
    {
        cout << test << endl;
        return;
    }

    int ans = ceil(right);
    cout << ans << endl;
}

signed main()
{
    getInput();
    solve();

    return 0;
}


Measured memory_bytes: 5336
#include<bits/stdc++.h>
using namespace std;
int odd(int n, int A[], int k)
{
    int i,j=0;
    for(i=0;i<n;i++)
    {
        if(A[i]>=k)
        {
            j++;
        }
    }

    return j;
}
int main()
{
    int  p,u;
    int c,B[100005],b;
    cin >> p >> c;
    for(u=0;u<p;u++)
    {
        cin >> B[u];
    }
    b=odd(p,B,c)
;
    cout << b <<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, t;
    cin >> n >> t;
    vector<P> ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = P(a, b);
    }
    sort(all(ab));
    auto dp = make_vec<int>(n+1, t);
    int ans = 0;
    rep(i, n) {
        int a = ab[i].fi, b = ab[i].se;
        chmax(ans, dp[i][t-1] + b);
        rep(j, t) {
            chmax(dp[i+1][j], dp[i][j]);
            if (j+a < t)chmax(dp[i+1][j+a], dp[i][j] + b);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 38544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	int x,y;
	cin>>x>>y;
	for(int i=0;i<=x;i++)
	{
		if((2*i+(x-i)*4)==y)
		{cout<<"Yes";return 0;}
	}
	cout<<"No";
}

Measured memory_bytes: 3620
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		TreeMap<Integer, Long> map = new TreeMap<Integer, Long>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			long b = sc.nextLong();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + b);
			} else {
				map.put(a, b);
			}
		}
		sc.close();

		long sum = 0L;
		for (int key : map.keySet()) {
			sum += map.get(key);
			if (sum >= k) {
				System.out.println(key);
				return;
			}
		}
	}
}


Measured memory_bytes: 97272
#include<stdio.h>

int main(){
    int a, b, ans;

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

    ans = a+b;

    if(a*b>ans){
        ans = a*b;
    }

    if(a-b>ans){
        ans = a-b;
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
def examA():
    X = I()
    if X<30:
        ans = "No"
    else:
        ans = "Yes"
    print(ans)
    return

def examB():
    N, D = LI()
    cnt = 0
    for _ in range(N):
        x, y = LI()
        if x**2+y**2<=D**2:
            cnt += 1
    ans = cnt
    print(ans)
    return

def examC():
    N = 10**7
    K = I()
    cur = 0
    now = 1
    ans = -1
    for i in range(N):
        cur += 7 * now
        cur %= K
        if cur==0:
            ans = i+1
            break
        now *= 10
        now %= K
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep,alphabet_convert
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main() {
  int A,B;
  cin >> A >> B;
  cout <<  max(A+B, max(A-B, A*B)) << endl;
  return 0;
}



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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {

	ll n, m, k;
	cin >> n >> m >> k;

	VLL a(n), b(m);
	REP(i, n)cin >> a[i];
	REP(i, m)cin >> b[i];

	VLL as(n + 1, 0), bs(m + 1, 0);
	REP(i, n)as[i + 1] = as[i] + a[i];
	REP(i, m)bs[i + 1] = bs[i] + b[i];

	ll ans = 0;
	REP(i, n + 1) {
		if (as[i] > k)continue;
		ll c = k - as[i];
		ll it = upper_bound(ALL(bs), c) - bs.begin();
		it--;
		ans = max(ans, it + i);
	}
	cout << ans << endl;

}

Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    string s;
    cin>>s;
    Yes(s[2] == s[3] && s[4] == s[5]);

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>
#include <map>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll L,R,d;
    cin >> L >> R >> d;
    cout << R/d - (L-1)/d << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        String res = "No";
        if (A == B) if (A != C) res = "Yes";
        if (A != B) if (A == C || B == C) res = "Yes";

        System.out.println(res);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int d;
  cin >> d;
  if (d == 25) {
    cout << "Christmas" << endl;
  }
  if (d == 24) {
    cout << "Christmas Eve" << endl;
  }
  if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  if (d == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}


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

using namespace std;

#define EPS (1e-7)
#define INF (1e9)


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rep2(i, n) for(int i = 1; i <= (n); i++)
#define all(a) begin(a),end(a)
#define endl '\n'




int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

inline void init(vector<int>& uf) {

    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {

    if(uf[x] == x) {

        return x;
    }
    else {

        return uf[x] = root(uf, uf[x]);
    }
}

inline bool same(vector<int>& uf, int x, int y) {

    return root(uf, x) == root(uf, y);
}

inline void unite(vector<int>& uf, int x, int y) {

    x = root(uf, x);
    y = root(uf, y);

    if(x == y) return;

    uf[x] = y;
}

int N;
void Input() {

    cin >> N;
}



void Solve() {


    vector<int> vec(N+2, 0);

    for(int i = 1; i <= N; i++) {

        cin >> vec[i];
    }

    int s = 0;



    for(int i = 0; i < N+1; i++) {

        s += abs(vec[i]-vec[i+1]);
    }

    for(int i = 1; i <= N; i++) {

        cout << s - (abs(vec[i-1]-vec[i]) + abs(vec[i]-vec[i+1])) + abs(vec[i-1]-vec[i+1]) << endl;
    }


}

int main() {

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


  return 0;

}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(3e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    string s;
    cin >> s;
    bool a[2][105][26]{};
    REP(i,s.size()){
        a[0][i][s[i]-'a'] = true;
    }
    int cnt = 0;
    while(1){
        bool f = false;
        REP(j,26){
            REP(i,s.size()-cnt){
                if(!a[0][i][j]){
                    break;
                }
                if(i==s.size()-cnt-1)f = true;
            }
        }
        if(f){
            cout << cnt << endl;
            break;
        }
        cnt++;
        REP(i,s.size()-cnt){
            REP(j,26){
                a[1][i][j] = a[0][i][j] || a[0][i+1][j];
            }
        }
        REP(i,s.size()-cnt){
            REP(j,26){
                a[0][i][j] = a[1][i][j];
            }
        }
    }
    return 0;
}


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

using namespace std;

int main(){

	int N;
	cin >> N;

	int count = 0;
	int yakusu;
	for (int i = 1; i <= N; i+=2){
		yakusu = 0;
		for (int j = 1; j <= i; j++){
			if (i%j == 0) yakusu++;
		}
		if (yakusu == 8){
			count++;
//			cout << i << endl;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 768
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int n, m;cin >> n >> m;
	int val[n + 1];memset(val, -1, sizeof val);
	bool ok = true;
	for(int i = 0; i < m; i++){
		int s, c;cin >> s >> c;
		if(val[s] == -1)val[s] = c;
		else if(c != val[s])ok = false;
	}
	if(!ok){cout << "-1";return 0;}
	if(n == 1){
		if(val[1] == -1)cout << 0;
		else cout << val[1];
		return 0;
	}
	if(val[1] == 0){cout << "-1";return 0;}
	if(val[1] == -1)val[1] = 1;
	string ans = to_string(val[1]);
	for(int i = 2; i <= n; i++){
		if(val[i] == -1)ans += '0';
		else ans += val[i] + '0';
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	string s;
	char c;
	s = "abcdefghijklmnopqrstuvwxyz";
	cin >> c;
	for (int i = 0; i <= s.size(); i++) {
		if (s[i] == c) {
			cout << s[i+1];
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		boolean[] is_prime = new boolean[200001];
		final int end = (int) Math.ceil(Math.sqrt(200000));
		
		Arrays.fill(is_prime, true);
		is_prime[0] = is_prime[1] = false;
		
		for(int i = 0; i <= end; i++){
			if(is_prime[i]){
				for(int j = 2 * i; j <= 200000; j += i){
					is_prime[j] = false;
				}
			}
		}
		
		ArrayList<Integer> p_list = new ArrayList<Integer>();
		for(int i = 0; i <= 200000; i++){
			if(is_prime[i]){
				p_list.add(i);
			}
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>(10000);
		while(true){
			final int N = sc.nextInt();
			final int P = sc.nextInt();
			
			if(N == -1 && P == -1){
				break;
			}
			
			list.clear();
			
			int start = Collections.binarySearch(p_list, N);
			if(start < 0){
				start = -(start + 1);
			}else{
				start++;
			}
			
			
			for(int i = 0; i < P; i++){
				for(int j = i; j < P; j++){
					list.add(p_list.get(start + i) + p_list.get(start + j));
				}
			}
			
			Collections.sort(list);
			System.out.println(list.get(P-1));
		}
	}

}

Measured memory_bytes: 66360
#include<stdio.h>

int main(void)
{
  int n,r;
  int p = 0;
  int c = 0;

  int a[50] = {0};
  int b[50] = {0};
  int i,j;
  
  while(1){
    scanf("%d %d",&n,&r);
    if(n == 0 &&r == 0)
      break;
    
    for(i = 0;i < n;i++){
      a[i] = n - i;
    }
    
    for(i = 0;i < r;i++){
      scanf("%d %d",&p,&c);
      for(j = 0;j < c;j++){
	b[j] = a[p-1+j];
      }
      
      for(j = 0;j < p-1;j++){
	b[c+j] = a[j];
      }
      for(j = 0;j < n-p-c+1;j++){
	b[p+c+j-1]= a[p+c+j-1];
      }

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

  
  

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

using namespace std;

const int MN = 2020;
const int INF = 1<<29;

int main() {
	int s, n, m;
	cin >> s >> n >> m;
	int x[s];
	for (int i = 0; i < s; i++) {
		cin >> x[i];
	}
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int t, p;
		cin >> t >> p; p--;
		v.push_back(t-x[p]);
	}
	sort(v.begin(), v.end());
	int vsm[MN];
	vsm[0] = 0;
	for (int i = 0; i < n; i++) {
		vsm[i+1] = vsm[i] + v[i];
	}
	
	static int dp[MN][MN];
	static int ar[MN][MN];
	
	for (int j = 1; j <= n; j++) {
		dp[0][j] = INF;
		ar[0][j] = 0;
	}
	for (int i = 0; i <= m; i++) {
		dp[i][0] = 0;
//		ar[i][0] = 0;
	}
	for (int i = 1; i <= m; i++) {
		ar[i][n+1] = n-1;
		for (int j = n; j >= 1; j--) {
			dp[i][j] = INF;
			ar[i][j] = ar[i][j+1];
			for (int k = ar[i-1][j]; k <= ar[i][j+1]; k++) {
				int ndp = dp[i-1][k] + v[j-1]*(j-k) - (vsm[j] - vsm[k]);
				if (ndp < dp[i][j]) {
					dp[i][j] = ndp;
					ar[i][j] = k;
				}
			}
		}
	}
	cout << dp[m][n] << endl;
	return 0;
}

Measured memory_bytes: 22116
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007

//逆元で二項係数を計算(MODは素数)　前処理O(n),本計算O(1)
#define MAXN 200000
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD%i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i*fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD*ifact[r] % MOD;
}





int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	init();
	long long ans = 0;
	for (int i = 0;;i++) {
		int y = h - a - i - 1;
		int x = b + i;
		if (y < 0 || x >= w)break;
		ans += C(y + x, y) * C(w + h - 2 - y - x, h - 1 - y);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <vector>
#include <map>
#include <sstream>
#include <string.h>
#include <algorithm>

#define INT_MIN (-2147483647 - 1)
#define INT_MAX 2147483647
#define lf double
#define ll long long int
#define f(i, n) for (ll i = 0; i < n; i++)

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    ll tc = 0, a = 0, b = 0, c = 0, x = 0, y = 0, m = 0, n = 0;

    cin >> a;
    cout << pow(a, 3) + pow(a, 2) + a;

    return 0;
}

Measured memory_bytes: 4188
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    map<string, int> ss;
    REP(n, N) {
        string s;
        cin >> s;
        sort(ALL(s));
        cerr << s << endl;
        ss[s] += 1;
    }

    ll ans = 0;
    for(auto kv: ss) {
        ll v = (ll)kv.second;
        if (v != 1) {
            ans += v * (v - 1) / 2;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11264
#include <iostream>

using namespace std;

int main(){
 long long int n, b, r;
  cin >> n >> b >> r;
  
  long long int val = n/(b+r);
  long long int ans = val*b;
  n = n - val*(b+r);
  ans = ans  + min(n,b);
  cout << ans;
  

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int n,a;
vi x;
vi pl,zl,ml;
int pn, mn;

int dpp[51][2501];
int dpm[51][2501];

int recp(int p, int val){
    if(dpp[p][val] != -1) return dpp[p][val];
    if(val == 0) return 1;
    if(p == pn) return 0;
    int res;
    if(val-pl[p] < 0) res = recp(p+1, val);
    else res = recp(p+1, val) + recp(p+1, val-pl[p]);
    dpp[p][val] = res;
    return res;
}

int recm(int p, int val){
    if(dpm[p][val] != -1) return dpm[p][val];
    if(val == 0) return 1;
    if(p == mn) return 0;
    int res;
    if(val-ml[p] < 0) res = recm(p+1, val);
    else res = recm(p+1, val) + recm(p+1, val-ml[p]);
    dpm[p][val] = res;
    return res;
}

int main()
{
    cin >> n >> a;
    x.resize(n); rep(i,n) cin >> x[i];
    rep(i,n){
       if(x[i] == a) zl.pb(0);
       else if(x[i] > a) pl.pb(x[i]-a);
       else ml.pb(a-x[i]);
    }

    sort(all(pl)); sort(all(ml));
    pn = pl.size(); mn = ml.size();

    rep(i,51){
        rep(j,2501){
            dpp[i][j] = -1;
            dpm[i][j] = -1;
        }
    }
    vi pc,mc;
    rrep(i,2500){
        int cp = recp(0,i);
        int cm = recm(0,i);
        //cout << i << ' ' << cp << ' ' << cm << endl;
        pc.pb(cp); mc.pb(cm);
    }

    ll ans = 0;
    rep(i,2500) ans += (ll)pc[i]*mc[i];
    ans++;
    ans *= (ll)pow(2,(int)zl.size());
    ans--;
    cout << ans;
}



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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sull(x) scanf("%llu",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf
#define clean fflush(stdout)

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};
///ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; /// 8 Direction
///ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; /// Knight Direction

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll bigmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=bigmod(a,b/2)%mod;
    x=(x*x)%mod;
    if(b%2)x=(x*a)%mod;
    return x;
}

ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
        ...ENDING OF TEMPLATE...
*/

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    /** Use "long double"(%Lf) instead of double for precision safety*/
    ll tst,a,b,c,k,n,m,ans=0,t=0;
    double num;
    sl(a),sf(num);
    b=num*100 + 0.5;
    ll res = (a*b)/100;
//    cout<<a<<" "<<b<<" "<<res<<endl;
    cout<<res<<endl;



    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000

vector<long long> func(vector<long long> A){
	int last = 0;
	for(long long i=60;i>=0;i--){
		int ind = -1;
		for(int j=last;j<A.size();j++){
			if((A[j]>>i) & 1LL){
				ind = j;
				break;
				swap(A[j],A[last]);
				ind = last;
				last++;
				break;
			}
		}
		if(ind==-1)continue;
		for(int j=0;j<A.size();j++){
			if(j!=ind){
				if((A[j]>>i)&1LL){
					A[j] ^= A[ind];
				}
			}
		}
		swap(A[last],A[ind]);
		last++;
	}
	while(A.back()==0)A.pop_back();
	return A;
}

bool check(vector<long long> &X,long long Y){
	for(int i=0;i<X.size();i++){
		for(long long j=60;j>=0;j--){
			if((X[i]>>j)&1){
				if((Y>>j)&1){
					Y ^= X[i];
				}
				break;
			}
		}
	}
	return (Y==0);
}

bool check(vector<long long> &X,vector<long long> &Y){
	
	for(int i=0;i<Y.size();i++){
		if(!check(X,Y[i]))return false;
	}
	
	return true;
}

int main(){
	
	int t;
	cin>>t;
	
	for(int _=0;_<t;_++){
		int N;
		cin>>N;
		
		vector<long long> A(N);
		for(int i=0;i<N;i++)cin>>A[i];
		
		string S;
		cin>>S;
		
		vector<long long> X,Y;
		bool f = true;
		for(int i=N-1;i>=0;i--){
			if(S[i]=='0'){
				X.push_back(A[i]);
				X = func(X);
			}
			else{
				Y.push_back(A[i]);
				Y = func(Y);
				if(!check(X,Y)){
					f=false;
					break;
				}
			}
		}
		if(f)cout<<0<<endl;
		else cout<<1<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
    int n;
    long z, w;
    scanf("%d %ld %ld", &n, &z, &w);
    int i;
    long a[n];
    for (i = 0; i < n; i++)
        scanf("%ld", &a[i]);
 
    if (n == 1)
        printf("%ld\n", labs(a[0] - w));
    else {
        if (labs(a[n - 1] - w) > labs(a[n - 2] - a[n - 1]))
            printf("%ld\n", labs(a[n - 1] - w));
        else
            printf("%ld\n", labs(a[n - 2] - a[n - 1]));
    }
 
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int v[n];
    for(int i=0;i<n;++i) cin >> v[i];
    sort(v, v + n);
    double ret = v[0];
    for(int i=1;i<n;++i)
    {
        ret = (ret + v[i]) / 2;
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
a, b, c = [int(x) for x in input().split()]
#a, b, c = [249999999, 250000000, 999999998]
d = c - a - b

if d <= 0:
    print("No")
else:
    if 4 * a * b < d * d:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 2940