akhauriyash/Code-Regression huggingface dataset:
#[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, 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")
    };
}
 
fn main() {
    input! {
        n: usize,
        v: [(usize, usize, usize); n-1],
    }

    let mut decided = vec![false; n+1];
    let mut visited = vec![false; n+1];
    visited[0] = true;

    //prepare for dfs
    let mut relation = vec![vec![]; n+1];

    // relation[src].push(dst, weight)
    for e in &v {
        relation[e.0].push((e.1, e.2));
        relation[e.1].push((e.0, e.2));
    }

    dfs(1, &relation, &mut decided, &mut visited);

    for e in decided.iter().skip(1) {
        let ans = if *e { 1 } else { 0 };
        println!("{}", ans);
    }    
}

fn dfs(node: usize, relation: &Vec<Vec<(usize, usize)>>, decided: &mut Vec<bool>, visited: &mut Vec<bool>) {

    for e in &relation[node] {
        if e.1 % 2 == 0 {
            decided[e.0] = decided[node];
        } else {
            decided[e.0] = !decided[node];
        }
        //println!("{}", e.0);
        if !visited[e.0] {
            visited[e.0] = true;
            dfs(e.0, &relation, decided, visited);
        }
    }
}



Measured memory_bytes: 21884
# dpD
import sys
input = sys.stdin.readline

def main():
    N, W = tuple(map(int, input().rstrip().split()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N))
    dp = [0] * (W + 1)
    for i in range(N):
        for j in range(W, A[i][0] - 1, -1):
            dp[j] = max(dp[j], dp[j - A[i][0]] + A[i][1])
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin >> a >> b;
	int total = 3*a + b;
	cout << total/2 << endl;
	return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;

int main(void){
    string S;cin>>S;
    REP(i,4-3){
        ll A=S[i]-'0';
        FOR(j,i+1,4-2){
            ll B=S[j]-'0';
            FOR(k,j+1,4-1){
                ll C=S[k]-'0';
                FOR(l,k+1,4){
                    ll D=S[l]-'0';
                    if(A+B+C+D==7){printf("%lld+%lld+%lld+%lld=7\n",A,B,C,D);}
                    else if(A+B+C-D==7){printf("%lld+%lld+%lld-%lld=7\n",A,B,C,D);}
                    else if(A+B-C+D==7){printf("%lld+%lld-%lld+%lld=7\n",A,B,C,D);}
                    else if(A+B-C-D==7){printf("%lld+%lld-%lld-%lld=7\n",A,B,C,D);}
                    else if(A-B+C+D==7){printf("%lld-%lld+%lld+%lld=7\n",A,B,C,D);}
                    else if(A-B+C-D==7){printf("%lld-%lld+%lld-%lld=7\n",A,B,C,D);}
                    else if(A-B-C+D==7){printf("%lld-%lld-%lld+%lld=7\n",A,B,C,D);}
                    else if(A-B-C-D==7){printf("%lld-%lld-%lld-%lld=7\n",A,B,C,D);}
                }
            }
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static void Main( string[] args )
    {
        List<string> spades = new List<string>( 13 );

        for ( int i = 0; i < 13; ++i ) {
            spades.Add( ( i + 1 ).ToString() );
        }

        List<string> hearts = new List<string>( spades );
        List<string> clubs = new List<string>( spades );
        List<string> diamonds = new List<string>( spades );

        int n = int.Parse( Console.ReadLine() );

        for ( int i = 0; i < n; ++i ) {
            string[] strings = Console.ReadLine().Split();

            switch ( strings[ 0 ] ) {
                case "S": { spades.Remove( strings[ 1 ] ); break; }
                case "H": { hearts.Remove( strings[ 1 ] ); break; }
                case "C": { clubs.Remove( strings[ 1 ] ); break; }
                case "D": { diamonds.Remove( strings[ 1 ] ); break; }

                default: { break; }
            }
        }

        Print( "S ", ref spades );
        Print( "H ", ref hearts );
        Print( "C ", ref clubs );
        Print( "D ", ref diamonds );
    }

    public static void Print( string prefix, ref List<string> list )
    {
        for ( int i = 0; i < list.Count; ++i ) {
            Console.WriteLine( prefix + list[ i ] );
        }
    }
}

Measured memory_bytes: 9260
import fractions as math

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a.sort()
# print(a)
gcd = a[1] - a[0]
for i in range(2, n+1):
    d = a[i] - a[i - 1]
    gcd = math.gcd(gcd, d)
print(gcd)


Measured memory_bytes: 16244
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int a[6],k,c=0;
      for(int i=0;i<5;i++)
        cin>>a[i];
      cin>>k;
      for(int i=0;i<5;i++)
        for(int j=i+1;j<5;j++)
          if(a[j]-a[i]<=k)
            c++;
      if(c==10)
        cout<<"Yay!";
      else
        cout<<":(";
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int b[26];
    for (int i = 0; i < 26; ++i) {
        b[i] = 0;
    }
    for (int i = 0; i < s.length(); ++i) b[s[i]-'a']++;

    for (int i = 0; i < 26; ++i) {
        if (b[i] == 0) {
            char ans = 'a'+i;
            cout << ans << std::endl;
            return 0;
        }
    }
    cout << "None" << std::endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read() {
	LL x = 0, fh = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') fh = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * fh;
}
const int N = 1e5 + 10;
int n, i, vis[N];
int main() {
	n = read();
	for (i = 2; ; i++) {
		vis[n] = 1;
		n = (n & 1 ? n * 3 + 1 : n / 2);
		if (vis[n]) break;
	}
	cout << i << '\n';
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%mod*res%mod)%mod;
    x=(x%mod*x%mod)%mod;    
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,mod-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/
// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/

void solve(){
    string s;
    cin>>s;
    string r=s;
    
    reverse(all(r));
    if(s!=r){
       cout<<"No";
       return;
    }
    
    int n=s.length();
    r=s.substr(0,n/2);
    
    string s1=r;
    reverse(all(s1));
    if(s1!=r){
       cout<<"No";
    }
    else
    cout<<"Yes";
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
import numpy as np
 
d,n = map(int, input().split())
if(not(n==100)):
  if(d==0):
    print(n)
  elif(d==1):
    print(100*n)
  else:
    print(10000*n)
else:
  if(d==0):
    print(101)
  elif(d==1):
    print(10100)
  else:
    print(1010000)

Measured memory_bytes: 27076
X = int(input())

if X >=1800 and X <=1999:
    print(1)
elif X >=1600 and X <=1799:
    print(2)
elif X >=1400 and X<=1599:
    print(3)
elif X >=1200 and X<=1399:
    print(4)
elif X >= 1000 and X <=1199:
    print(5)
elif X >= 800 and X <= 999:
    print(6)
elif X >= 600 and X <= 799:
    print(7)
elif X >= 400 and X <= 599:
    print(8)

Measured memory_bytes: 9196
n = int(input())
list_a = list(map(int, input().split()))
m = max(list_a)
search = m/2
min_a = abs(list_a[0] - search)
min_ind = 0
for i in range(n):
    if min_a > abs(list_a[i] - search):
        min_a = abs(list_a[i] - search)
        min_ind = i
if list_a[min_ind] == m:
    print(m,0)
else:
    print(m, list_a[min_ind])


Measured memory_bytes: 14428
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 31);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int n, ans = 0; string s,t="810";
vector<char> c = { '0','1','2','3','4','5','6','7','8','9' };
void dfs(int i) {
    if (i == 3) {
        int id = 0;
        rep(l, n) {
            if (s[l] == t[id]) id++;
            if (id > 2) {
                ans++;
                break;
            }
        }
    }
    else {
        rep(j, 10) {
            t[i] = c[j];
            dfs(i+1);
        }
    }
}
int main() {
    cin >>n >>s; 
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


struct b{int w,s,v;};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<b>bs(n);
  rep(i,n)
  {
    cin>>bs[i].w>>bs[i].s>>bs[i].v;
  }
  sort(all(bs),[](b p,b q){if(p.s+p.w!=q.s+q.w)return p.s+p.w<q.s+q.w;return p.s<q.s;});
  vector<ll>dp(20001,-1);
  dp[0]=0;
  rep(i,n)
  {
    for(int j=bs[i].s;j>=0;j--)
    {
      if(dp[j]==-1)continue;
      chmax(dp[j+bs[i].w],dp[j]+bs[i].v);
    }
  }
  auto res=(*max_element(all(dp)));
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 384
import itertools

def main():
    n,m,x = map(int,input().split())
    c = [[0] * (m+1)]*n
    sum_l = [0]*m
    min_money = 100000000
    money = 0
    cnt = 0
    t = 0

    result  = []

    for i in range(n):
        c[i] = list(map(int,input().split()))

    for i in range(1,n+1):
        for conb in itertools.combinations(list(range(n)),i):
            result.append(list(conb))
            cnt += 1

    # print(result)
    # print(cnt)
    for i in range(cnt):
        for j in range(len(result[i])):
            for k in range(m):
                sum_l[k] += c[result[i][j]][k+1]
            money += c[result[i][j]][0]

            for k in range(m):
                if sum_l[k] >= x:
                    t += 1
            if t == m:
                if min_money > money:
                    min_money = money
            t = 0
        # print(result[i],sum_l,money,min_money)
        sum_l = [0]*m
        money = 0

    if min_money == 100000000:
        print(-1)
    else:
        print(min_money)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
long di(long n,long num){
    if(n%2==0){
        return di(n/2,num+1);
    }
    else{
        return num;
    }
}
int main(){
    int n;
    cin>>n;
    long  a[n];
    long ans =99999999999;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        ans =min(ans,di(a[i],0));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3e2;
 
int n;
long long g[N+10][N+10],ans;
bool bo[N+10][N+10];
 
int main(){
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    for (int i = 1;i <= n;i++)
        for (int j = 1;j <= n;j++){
            cin >> g[i][j];
            if (j > i) ans+=g[i][j];
        }
 
    for (int i = 1;i <= n;i++)
        for (int j = 1;j <= n;j++)
            if (g[i][j]!=g[j][i])
                return cout <<-1<<endl,0;
 
    for (int k = 1;k <= n;k++)
        for (int i = 1;i <= n;i++)
            if (k!=i)
                for (int j = 1;j <= n;j++)
                    if (k!=j && i!=j)
                        if (g[i][j]>g[i][k]+g[k][j])
                            return cout<<-1<<endl,0;
                        else
                            if (g[i][j]==g[i][k]+g[k][j] && !bo[i][j]){
                                    ans -= g[i][j];
                                    bo[i][j] = true;
                                    bo[j][i] = true;
                            }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
	ll A1, A2, A3; cin >> A1 >> A2 >> A3;

	if (A1 + A2 + A3 >= 22) {
		cout << "bust";
	}
	else {
		cout << "win";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  string a,b,c;cin>>a>>b>>c;
  cout<<a[0]<<b[0]<<c[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, *input().split())

op = 0
while True:
    if A + (B if op & 1 else -B) + (C if op & 2 else -C) + (D if op & 4 else -D) == 7:
        break
    op += 1

print(A, '+' if op & 1 else '-', B, '+' if op & 2 else '-', C, '+' if op & 4 else '-', D, '=7', sep='')


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
using namespace std;
int main()
{
	vector<long long int> v;
	int n; cin >> n; int a[200000],b[200000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] != 2) {
			cin >> b[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == 0)
			v.push_back(b[i]);
		if (a[i] == 1)
			cout << v[b[i]] << endl;
		if (a[i]==2)
			v.pop_back();
	}
}


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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    if(n%2){
        cout << (n-1)*(n-1)/2 << endl;
        for(i = 1;i < n;i++){
            for(j = i+1;j <= n;j++){
                if(i+j != n) cout << i << ' ' << j << endl;
            }
        }
    }
    else{
        cout << n*(n-2)/2 << endl;
        for(i = 1;i < n;i++){
            for(j = i+1;j <= n;j++){
                if(i+j != n+1) cout << i << ' ' << j << endl;
            }
        }
    }
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint inf=std::numeric_limits<lint>::max();
    lint n;std::cin>>n;
    lint sum=0,min=inf;
    for(lint i=0;i<n;i++){
        lint x;
        std::cin>>x;
        sum+=x;
        cmn(min,x);
    }
    std::cout<<(sum%2==0&&(n%2==1||min%2==0)?"Second":"First")<<'\n';
}



Measured memory_bytes: 3220
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int res = 0;
  cout << min(a, b) + min(c, d) << endl;
  return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

vector<ll> f(ll num)
{
	vector<ll> v;
	while (num)
	{
		v.push_back(num%10);
		num/=10;
	}
	return v;
}

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> D(K); REP(i, K) cin >> D[i];

	while (true)
	{
		vector<ll> v = f(N);
		bool ok{true};
		REP(i, K)
		{
			auto pos = find(v.begin(), v.end(), D[i]);
			if (pos != v.end()) ok = false;
		}
		if (ok) break;
		++N;
	}

	std::cout << N << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <limits>
#include <algorithm>
#include <queue>
#include <vector>
#include <numeric>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <tuple>
#include <cassert>

#ifndef IO_H
#define IO_H

#include <cstdio>
#include <limits>

namespace {

class TokenizeReader {
public:
  TokenizeReader() = delete;
  TokenizeReader(FILE* file, int buffer_len);
  ~TokenizeReader();
  void Read(char* s, size_t& len, int max_len = std::numeric_limits<int>::max());
  bool HasNext();
  int NextInt();
private:
  bool EnsureRead();
  bool IsInValidCharacter(int c);

  FILE* file_;
  char* buffer_;
  int buffer_len_, pos_, read_n_;
  bool end_ = false;
};

TokenizeReader::TokenizeReader(FILE* file, int buffer_len)
  : file_(file), buffer_len_(buffer_len), pos_(0), read_n_(0) {
  buffer_ = new char[buffer_len_];
}

TokenizeReader::~TokenizeReader() {
  delete buffer_;
}

void TokenizeReader::Read(char *s, size_t &len, int max_len) {
  len = 0;
  while (EnsureRead() && IsInValidCharacter(buffer_[pos_])) pos_++;
  while ((int) len < max_len && EnsureRead()
      && !IsInValidCharacter(buffer_[pos_])) {
    s[len++] = buffer_[pos_++];
  }
}

bool TokenizeReader::HasNext() {
  static size_t unused;
  Read(nullptr, unused, 0);
  return EnsureRead();
}

int TokenizeReader::NextInt() {
  static char buf[21];
  size_t len;
  int value;
  Read(buf, len, 20);
  if (len == 0) throw -1;
  buf[len] = 0;
  sscanf(buf, "%d", &value);
  return value;
}

bool TokenizeReader::EnsureRead() {
  if (pos_ < read_n_) {
    return true;
  } else if (end_) {
    return false;
  }
  read_n_ = ::fread(buffer_, 1 /* size */, buffer_len_, file_);
  pos_ = 0;
  end_ = read_n_ == 0;
  return !end_;
}

bool TokenizeReader::IsInValidCharacter(int c) {
  return c == ' ' || c == '\t' || c == '\n' || c == EOF;
}

}

#endif  // IO_H

namespace {

#define for_each_test_cases(T, BUFFSIZE)            \
  TokenizeReader reader(::stdin, BUFFSIZE);         \
  int T;                                            \
  scanf("%d", &T);                                  \
  for (int cas = 1; cas <= T; cas++)

}  // namesapce

const int MaxN = 100005;
int a[3][MaxN];
long long dp[3][MaxN];

int main() {
  int n;

  while (scanf("%d", &n) == 1) {
    for (int k = 0; k < 3; k++) {
      for (int i = 0; i < n; i++) scanf("%d", &a[k][i]);
      std::sort(a[k], a[k] + n);
    }
    for (int i = 0; i < n; i++) {
      dp[0][i] = i + 1;
    }
    for (int k = 1; k < 3; k++) {
      for (int i = 0, j = 0; i < n; i++) {
        while (j < n && a[k - 1][j] < a[k][i]) j++;
        dp[k][i] = j ? dp[k - 1][j - 1] : 0;
        if (i) dp[k][i] += dp[k][i - 1];
      }
    }
    printf("%lld\n", dp[2][n - 1]);
  }
  
  return 0;
}



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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
const int maxn = 105;

int ans[maxn][maxn], n, m, tot, a[maxn*maxn];
int x, y, d;

int main()
{
	scanf("%d%d%d",&n,&m,&tot);
	fo(i,1,tot) scanf("%d",&a[i]);
	x = 1; y = 1; d = 1;
	fo(i,1,tot)
	{
		while(a[i]--)
		{
			ans[x][y] = i;
			if((y == m && d == 1) || (y == 1 && d == -1)) {++ x; d = (d==1?-1:1);}
			else y += d;
		}
	}
	fo(i,1,n) {fo(j,1,m) printf("%d ",ans[i][j]); printf("\n");}
	return 0;
}

Measured memory_bytes: 384
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
	int n;
	int k;
	long[] h;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto array = readln().strip().split();
        n = array[0].to!int;
        k = array[1].to!int;
		h = readln().strip().split().map!(to!long).array;
	}
}

struct Output
{
}

auto main2(Input* input)
{
    input.h.sort!"a>b";

    if (input.k < input.n)
        return sum(input.h[input.k..$]);
    else
        return 0;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`3 1
4 1 5`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 5);
}

unittest // example2
{
	string example =
`8 9
7 9 3 2 3 8 4 6`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 0);
}

unittest // example3
{
	string example =
`3 0
1000000000 1000000000 1000000000`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 3000000000);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


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

public class Main{
	public static int max = 0;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] str = (br.readLine()).split(" ");
		int[] num = new int[n];
		for (int i = 0; i<n ; i++ ) {
			num[i] = Integer.parseInt(str[i]);
		}

		int part = partition(num,0,n-1);

		for (int i = 0; i<n ; i++ ) {
			if (i == n-1) {
				System.out.println(num[i]);
			}else if (i == part){
				System.out.print("[" + num[i] + "] ");
			}else{
				System.out.print(num[i] +" ");
			}
		}

	}

	public static int partition(int[] a ,int p,int r){
		int x = a[r];
		int i = p-1;
		for (int j = p; j<r ; j++ ) {
			if (a[j] <= x)  {
				i++;
				int work = a[i];
				a[i] = a[j];
				a[j] = work; 
			}
		}
		int num = a[i+1];
		a[i+1] = a[r];
		a[r] = num;

		return i+1;
	}

	public static void printing(int[] a){
		for (int i = 0; i<a.length ; i++ ) {
			if (i == a.length-1) {
				System.out.println(a[i]);
			}else{
				System.out.print(a[i] + " ");
			}
		}
	}
}

Measured memory_bytes: 61508
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 100031;

int n;
int D[500][500];
int m,r;
vector<int> order;

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

	cin>>n>>m>>r;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			D[i][j]=1e9;
		}
	}

	for (int i=1;i<=r;i++)
	{
		int val;
		cin>>val;
		order.push_back(val);
	}

	for (int i=1;i<=m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		D[a][b]=min(D[a][b],c);
		D[b][a]=min(D[b][a],c);
	}

	for (int k=1;k<=n;k++)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=n;j++)
			{
				D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
			}
		}
	}

	int ans=1e9;

	sort(order.begin(),order.end());
	do{
		int here=0;
		for (int i=1;i<order.size();i++)
		{
			here+=D[order[i-1]][order[i]];
		}
		ans=min(ans,here);
	}while (next_permutation(order.begin(),order.end()));

	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 640
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [usize; n],
    }

    if n < 3 {
        println!("{}", 0);
        return;
    }

    l.sort();

    let mut ans = 0;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            for k in (j + 1)..n {
                if l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
                    ans += 1;
                }
            }
        }
    }

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


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */
 
const double PI = acos(-1);
 
signed main(){
    int r;
    cin >> r;
    cout << 2*r*PI << "\n";
}

Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int arr[n],sum(0);
for(int i=0; i<n; ++i)
cin>>arr[i];
sort(arr,arr+n);
for(int i=0; i<k; ++i)
sum+=arr[i];
cout<<sum;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> t(n);
  for(int x = 0; x<n; x++){
    cin >> t[x];
  }
  sort(t.begin(), t.end());
  int mid=n/2;
  if(t[mid]!=t[mid-1]){
    cout << t[mid]-t[mid-1] << endl;
  }
  else
    cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

deque<int> col;



int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    col.push_front(a[0]);
    for (int i = 1; i < n; i++){
        int idx = lower_bound(col.begin(), col.end(), a[i]) - col.begin();
        if(idx == 0){
            col.push_front(a[i]);
        }else{
            col[idx-1] = a[i];
        }
    }
    int ans = col.size();
    cout << ans << endl;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans=0,res=0;
    if(a[0]<=b[0]){
        ans+=a[0];
        res=b[0]-a[0];
    }else{
        ans+=b[0];
    }
    for(int i=1;i<n;++i){
        if(res>=a[i]){
            res=b[i];
            ans+=a[i];
        }else{
            ans+=res;
            a[i]-=res;
            if(a[i]<=b[i]){
                ans+=a[i];
                res=b[i]-a[i];
            }else{
                ans+=b[i];
                res=0;
            }
        }
    }
    if(res>=a[n]) ans+=a[n];
    else ans+=res;
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 4696
#include <stdio.h>
void swap(double *x,double *y){
    double t = *x;
    *x = *y;
    *y = t;
}
int minChild(double *ar,int len,int r,int x,int y){
    if(x<len && ar[r]>ar[x]) r = x;
    if(y<len && ar[r]>ar[y]) r = y;
    return r;
}
void heapify(double *ar,int len,int r){
    int c = minChild(ar, len, r, 2*r+1, 2*r+2);
    if(c!=r){
        swap(&ar[r],&ar[c]);
        heapify(ar,len,c);
    }
}
double getTop(double *ar,int len){
    double top = ar[0];
    ar[0]=ar[len];
    heapify(ar,len,0);
    return top;
}
void insert(double *ar,int len,double val){
    ar[len] = val;
    while (len>0 && ar[(len-1)/2]>ar[len]){
        swap(&ar[len],&ar[(len-1)/2]);
        len = (len-1)/2;
    }
}
void MRoy(){
    int N;
    double v[1001],heap[1001];
    scanf("%d",&N);
    int len = 0;
    for(int i = 0;i<N;i++){
        scanf("%lf",v+i);
        insert(heap,len,v[i]);
        len++;
    }
    while(len>1){
        double x = getTop(heap,--len);
        double y = getTop(heap,--len);
        // printf("%lf %lf ",x, y);
        insert(heap,len,(x+y)/2);
        len++;
    }
    printf("%.10lf\n",heap[0]);
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
constexpr ll MOD = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int mp[10][10] = {0};
	
	for(int i = 1; i <= n; ++i) {
		string s = to_string(i);
		mp[s[0] - '0'][s.back() - '0']++;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		string s = to_string(i);
		ans += mp[s.back() - '0'][s[0] - '0'];
	}
	
	cout << ans << endl;
	
	return 0;
}


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

const int L = 128, Sig = 62;

inline char itoc(int x) { return x < 10 ? x + '0' : x < 36 ? x - 10 + 'A' : x - 36 + 'a'; }

int nums[Sig], len;

std::string Solve(int l, int r) {
	std::string ret;
	if (r - l == 1) {
		int x = nums[l];
		while (x) ret += itoc(l), --x;
		return ret;
	}
	int mid = (l + r) / 2;
	std::string left = Solve(l, mid);
	std::string right = Solve(mid, r);
	int lp = 0, rp = 0;
	while (lp < (int)left.length() && rp < (int)right.length()) {
		printf("? ");
		std::cout << ret << right[rp] << left.substr(lp);
		putchar('\n'), fflush(stdout);
		int num;
		scanf("%d", &num);
		if (num == len - ((int)left.length() + rp + 1)) ret += right[rp++];
		else ret += left[lp++];
	}
	return ret + left.substr(lp) + right.substr(rp);
}

int main() {
	for (int i = 0; i < Sig; ++i) {
		printf("? ");
		for (int j = 0; j < L; ++j) putchar(itoc(i));
		putchar('\n'), fflush(stdout);
		int num;
		scanf("%d", &num);
		nums[i] = L - num;
		len += nums[i];
	}
	std::string ans = Solve(0, Sig);
	std::cout << "! " << ans << std::endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    string w[n];
    for(int i=0;i<n;i++) cin >> w[i];

    bool ok = true;

    for(int i=0;i<n-1;i++){
        if(w[i].at(w[i].size()-1) != w[i+1].at(0)) ok = false;
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<i;j++){
            if(w[i] == w[j]) ok = false;
        }
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
s, t = input().split()
num = list(map(int, input().split()))
u = input()

if u == s:
  nums = num[0] -1
  numt = num[1]
else:
  nums = num[0]
  numt = num[1] -1

l = str(nums) + " " + str(numt)
print(l)


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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n,m,u,v;
    cin>>n>>m;
    ll h[n+10];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    vector<vector<int> > graph(n+4);
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    ll c=0;
    for(int i=1;i<=n;i++)
    {
        vector<int > y= graph[i];
        bool ans=true;
        for(auto e:y)
        {
            if(h[e]>=h[i])
                ans=false;
        }
        // if(ans)
        //     cout<<i<<"\n";
        c+=ans;
    }
    cout<<c<<"\n";
    return 0;   
}

Measured memory_bytes: 9224
#include <cstdio>
#include <string>
#include <cstring>

using namespace std;

int main(){
	string str,s;
	int n,l;
	char c;
	char cs[65536];
	char cself[256];
	char *ptr;
	int self;
	while(1){
		scanf("%d",&n);
		if(n == 0){break;}
		scanf("%s",cs);
		str = cs;
		
		for(int i=0;i<n;i++){
			strcpy(cs,str.c_str());
			//printf("-->%s\n",cs);
			ptr = cs;
			s = "";
			while(*ptr != '\0'){
				//printf("%c\n",*ptr);
				c = *ptr;
				self = 1;
				while( *(ptr + 1) == c){
					self++;
					ptr++;
				}
				sprintf(cself,"%d%c",self,c);
				s += cself;
				ptr++;
			}
			str = s;
		}
		printf("%s\n",str.c_str());
	}
}

Measured memory_bytes: 0
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int N, W, vi, wi;
    readVars(N, W);

    auto v = new int[](N);
    auto w = new int[](N);

    foreach(i ; 0 .. N){
        readVars(vi, wi);
        v[i] = vi;
        w[i] = wi;
    }

    auto dp = new int[](W + 1);

    foreach(i ; 0 .. N){
        foreach_reverse(j ; w[i] .. W + 1){
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }

    int ans = dp[W];

    writeln(ans);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 2752
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{

    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        
        int I = int.Parse(s[0]);
        int J = int.Parse(s[3]);
        int L = int.Parse(s[4]);
        long ansa, ansb;
        ansa = int.Parse(s[1]);
        ansb = int.Parse(s[1]);
        if (I > 0 && J > 0 && L > 0)
        {
            ansa += 3;
            ansa += (I - 1) / 2 * 2;
            ansa += (J - 1) / 2 * 2;
            ansa += (L - 1) / 2 * 2;
        }
        ansb += I / 2 * 2;
        ansb += J / 2 * 2;
        ansb += L / 2 * 2;
        Console.WriteLine(Math.Max(ansa,ansb));
    }
    
}




Measured memory_bytes: 2648
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main()
{
  const int INF = 1 << 30;
  const int m[] = {4, 1, 4, 1, 2, 1, 2, 1};
  vector<int> p(8);
  while (~scanf("%d %d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6], &p[7])) {
    int cnt = INF;
    string ans = "99999999";
    for (int i = 0; i < 8; ++i) {
      int tmp = 0;
      string ts = "";
      for (int j = 0; j < 8; ++j) {
	if (p[j] - m[(i+j)%8] > 0)
	  tmp += p[j] - m[(i+j)%8];
	ts += (m[(i+j)%8] + '0');
      }
      if (tmp < cnt) {
	cnt = tmp;
	ans = ts;
      } else if (tmp == cnt) {
	if (ts < ans)
	  ans = ts;
      }
    }

    for (int i = 0; i < 7; ++i)
      printf("%c ", ans[i]);
    printf("%c\n", ans[7]);
  }
  return 0;
}

Measured memory_bytes: 0
from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))

cums = [0]
for a in A:
    cums.append((cums[-1] + a) % M)
ctr = Counter(cums)

ans = 0
for v in ctr.values():
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 16552
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int a,b;cin>>a>>b;
    cout << b*2-a<<endl;
}

int main(){
//option:-std=c++0x
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;


void solve(){
    int a , b ;
    cin >> a >> b ;
    int ans = a*b ;
    cout << ans << endl ;

}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    c = [1] * (N+1)
    for i in range(2, N+1):
        for j in range(i, N+1, i):
            c[j] += 1
    # print(c)
    ans = 0
    for i in range(1, N+1):
        ans += i * c[i]
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


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

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() {
    int N;
    cin >> N;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];
    vector<ll> dp(N);
    rep(i, N) dp[i] = INF;
    dp[0] = 0;
    repX(i,N,1){
        chmin(dp[i], dp[i - 1]+abs(h[i] - h[i - 1]));
        if(i>1)chmin(dp[i], dp[i - 2]+abs(h[i] - h[i - 2]));
    }
    cout << dp[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

int main() {
  string str;
  cin >> str;
  ll nn = (ll)str.size();

  ll cnt = 0;
  for (size_t i = 0; i < str.size(); i++) {
    if (str[i] == 'p') cnt++;
  }

  cout << nn/2 - cnt << endl;

  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;

char s1[100], s2[100];
int n;

int get(char* s) {
  int ans = 0;
  for (int i = 0; s[i] != 0; i++) {
    if (s[i] == 'm') { ans += 1000; continue; }
    if (s[i] == 'c') { ans += 100; continue; }
    if (s[i] == 'x') { ans += 10; continue; }
    if (s[i] == 'i') { ans += 1; continue; }
    if (s[i + 1] == 'm') { ans += (int)(s[i] - '0') * 1000, i++; continue; }
    if (s[i + 1] == 'c') { ans += (int)(s[i] - '0') * 100, i++; continue; }
    if (s[i + 1] == 'x') { ans += (int)(s[i] - '0') * 10, i++; continue; }
    if (s[i + 1] == 'i') { ans += (int)(s[i] - '0') * 1, i++; continue; }
  }
  return ans;
}

void make(int m) {
  int a1 = m / 1000;
  if (a1 > 1) printf("%dm", a1);
  if (a1 == 1) printf("m");
  m %= 1000;

  int a2 = m / 100;
  if (a2 > 1) printf("%dc", a2);
  if (a2 == 1) printf("c");
  m %= 100;

  int a3 = m / 10;
  if (a3 > 1) printf("%dx", a3);
  if (a3 == 1) printf("x");
  m %= 10;

  int a4 = m;
  if (a4 > 1) printf("%di", a4);
  if (a4 == 1) printf("i");

  printf("\n");
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%s", s1, s2);
    int ans = get(s1);
    ans += get(s2);
    make(ans);
  }
}



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

typedef long long ll;

int main(){
        int n;
        cin>>n;
        int ans=0,MIN=1e9;
        vector<int>p(n);
        for(int i=0;i<n;i++){
                cin>>p[i];
                if(p[i]<MIN)MIN=p[i],ans++;
        }
        cout<<ans<<endl;
        return 0;
}                                                                                      

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a < b) {
			System.out.println(Math.max(0, b-(a + W)));
		} else {
			System.out.println(Math.max(0, a-(b+W)));
		}
	}
}


Measured memory_bytes: 23764