akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
double max(double a, double b){
     return a > b ? a : b;
}

#define inf 1e9

int main()
{
     cin.sync_with_stdio( false );

     int h;
     cin>>h;

     vector <int> dp(h+5, inf); dp[0] = 0;

     int n;
     cin>>n;

     pair <int, int> att[n];
     for (int i=0;i<n;i++){
          int a,b;
          cin>>a>>b;
          att[i] = {a, b};
     }

     for (int i=0;i<n;i++){
          for (int j=0;j<=h;j++){
               if ( dp[j] != inf ){
                    //pozicija j ali - a - skidas -> j + a
                    dp[min(j+att[i].first, h)] = min(dp[min(j+att[i].first, h)], dp[j] + att[i].second);
               }
          }
     }

     cout<<dp[h]<<endl;
}

Measured memory_bytes: 3588
#include <iostream>

int main()
{
    int N;
    int s[101];
    std::cin>>N;
    int i, sum = 0;
    for ( i = 1; i <= N; i++ ) {
        std::cin >> s[i];
        sum += s[i];
    }

    if ( sum % 10 != 0 ){
        std::cout << sum << std:: endl;
        return 0;
    } else {
        int a[101];
        for ( i = 1; i <= 100; i++ ) {
            a[i] = 0;
        }
        for ( i = 1; i <= N; i++ ) {
            a[ s[i] ]++;
        }
        for ( i = 1; i <= 100; i++ ){
            if ( i  % 10 != 0 && a[i] > 0 ) {
                std::cout << ( sum -  i ) << std::endl;
                return 0;
            }
        }
        std::cout << 0 << std::endl;
        return 0;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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





using namespace std;
int main() {

	int a, b, c;
	cin >> a >> b >> c;

	c -= (a - b);
	if (c > 0)cout << c << endl;
	else cout << 0 << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    ll n,k,q;
    cin >> n >> k >> q;

    ll correctNum[n];
    for (ll i = 0; i < n; i++)
    {
        correctNum[i] = 0;
    }
    
    for (ll i = 0; i < q; i++)
    {
        ll no = 0;
        cin >> no;

        correctNum[no-1]++;
    }
    
    for (ll i = 0; i < n; i++)
    {
        ll remain = k - (q - correctNum[i]);
        if (remain > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n);
    map<int, int> M;
    rep(i, n) {
        cin >> A[i];
        ++M[A[i]];
    }

    sort(all(A));

    int maxA = A[n - 1] + 100;
    vector<bool> check_table(maxA + 1, false);
    int k;
    rep(i, n) {
        k = 2;
        while (A[i]*k <= maxA) {
            check_table[A[i]*k] = true;
            ++k;
        }
    }

    // A.erase(unique(all(A)), A.end());
    int ans = 0;
    rep(i, (int)A.size()) {
        if (! check_table[A[i]] && M[A[i]] == 1) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13616
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    map<char,int> al;
    int n = s.size();
    set<char> st;
    for(int i = 0; i < 26; i++){
        al['a'+i]++;
    }
    for(int i = 0; i < n; i++){
        al[s[i]]--;
        st.insert(s[i]);
    }
    if(st.size() == 26){
        cout << "None" << endl;
    }
    else{
        for(auto p:al){
            if(p.second > 0){
                cout << p.first << endl;
                break;
            }
        }
    }    

}

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

signed main(){
    int n,w;cin>>n>>w;
    int dp[n+1][w+1];
    fill(dp[0],dp[n+1],0);
    rep(i,n){
        int ww,vv;cin>>ww>>vv;
        rep(j,w+1){
            if(j>=ww){
                dp[i+1][j]=max(dp[i][j],dp[i][j-ww]+vv);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

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

int A,B;
string S;
int main(){
	while(cin >> A >> B){
		cin >> S;
		bool judge = true;
		for(int i=0;i<S.size();i++){
			if(i<A || i>A){
				if(S[i]=='-') judge = false;
			}
			if(i==A){
				if(S[i] != '-') judge = false;
			}
		}
		if(judge) cout << "Yes"<< endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define ll long long int

const int M = 1000005;

int main()
{
    ll N;

    cin >> N;
    vector<int> a(N);
    vector<int> cnt(M);
    for (ll i=0; i<N; i++){
        cin >> a[i];
    }

    for (int x : a){
        if (cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for (int k = x; k < M; k+=x) {
            cnt[k]++;
        }
    }
    int ans = 0;

    for (int x : a) {
        if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int n,k; cin>>n>>k;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int ans=inf<int>();
	rep(i,n-k+1)
		ans=min(ans,a[i+k-1]-a[i]);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
const ll mod=2019 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main() {
   int n,m ;
   cin >> n>>m ;
   vector<int> H(n) ;
   rep(i,n) cin >> H[i] ;
   vector<int> AB(2*m) ;
   rep(i,2*m) cin >> AB[i] ;
   vector<int> cnt(n) ;
   rep(i,m) {
     if(H[AB[2*i]-1]>=H[AB[2*i+1]-1])
     cnt[AB[2*i+1]-1] = -1 ;
     if(H[AB[2*i]-1]<=H[AB[2*i+1]-1])
    cnt[AB[2*i]-1] = -1 ;
  
   }   
   ll ans=n ;
   rep(i,n){
     if(cnt[i]==-1)
     ans-- ;
   }
   cout<<ans <<endl;
    return 0;
}



Measured memory_bytes: 4844
# coding: utf-8

N, C = map(int, input().split())
x_list = []
v_list = []
for i in range(N):
    xi, vi = map(int, input().split())
    x_list.append(xi)
    v_list.append(vi)

e_clock = [0] * N
e_counter = [0] * N
e_clock0 = [0] * N # 時計回りしたあと、初期位置に戻った状態
e_counter0 = [0] * N # 反時計回りしたあと、初期位置に戻った状態

# 時計回り、反時計回りはそれぞれ多くて１回ずつである
# (何度も切り替えしても、距離だけ増えて効率的でない

# 時計回りに回ったときの各地点までの取得エネルギーで最大値を格納する
cal = 0
e = 0
e0 = 0
for i in range(N):
    cal += v_list[i]
    x = x_list[i]
    e = max(e, cal - x)
    e0 = max(e0, cal - 2*x)

    e_clock[i] = e
    e_clock0[i] = e0


# 反時計回りに回ったときの各地点までの取得エネルギーで最大値を格納する
cal = 0
e = 0
e0 = 0
for i in range(N-1, -1, -1):
    cal += v_list[i]
    x = C - x_list[i]
    e = max(e, cal - x)
    e0 = max(e0, cal - 2*x)
    e_counter[i] = e
    e_counter0[i] = e0

ans = 0

for i in range(N-1):
    # 時計回りのあと、反時計回りをしたとき
    e1 = e_clock0[i] + e_counter[i+1]
    # 反時計回りのあと、時計回りをしたとき
    e2 = e_counter0[i+1] + e_clock[i]

    ans = max(ans, e1, e2)

# 上はrange(N-1)のforなので
# 時計回りと反時計回りのそれぞれでまるまる１周した場合も加える
ans = max(ans, e_clock[N-1], e_counter[0])

print(ans)

Measured memory_bytes: 23512
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = n * a
    dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for k in range(n):
            for s in range(MAX):
                dp[i][k][s] += dp[i - 1][k][s]
                if s + x <= MAX:
                    dp[i][k + 1][s + x] += dp[i - 1][k][s]
    res = 0
    for k in range(1, n + 1):
        res += dp[-1][k][a * k]
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 118188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
		if(s[i]!=s[j])
		{
			cout<<"No";
			return 0;
		}
		i++,j--;
	}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n,b,r,br,n1,n2,last_b=0;
    cin>>n>>b>>r;
    br=b+r;
    if(b==0)
        cout<<0<<endl;
    else
    {
        n1 = n/br;
        n2 = n%br;
        if(n2>b)
            last_b=b;
        else
            last_b=n2;
        cout<<n1*b+last_b<<endl;
    }

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[200010];
bool fl[2000010];
ll ma;
ll ans;
ll cnt[2000010];

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

  rep( i, N ) {
    std::cin >> A[i];

    ++cnt[A[i]];
  }

  std::sort( A, A+N );

  rep( i, N ) if( !fl[A[i]] ) {
    if( cnt[A[i]] == 1 )
      ++ans;

    for( ll j = 1; j*A[i] <= 1000000; ++j ) {
      fl[j*A[i]] = true;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 13888
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        odd = {'R', 'U', 'D'}
        even = {'L', 'U', 'D'}

        for i, c in enumerate(list(S)):
            if (i + 1) % 2 != 0:
                if c not in odd:
                    print('No')
                    exit()
            else:
                if c not in even:
                    print('No')
                    exit()
        print('Yes')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    vector<int> A(5);

    for(int i = 0;i < 5;i++){
        cin >> A.at(i);
    }

    for(int i = 0;i < 5;i++){
        if(A.at(i) == 0){
            cout << i + 1 << endl;
            break;
        }
    }
    
}

Measured memory_bytes: 3456
#!/usr/bin/ruby
n,k=gets.split.map &:to_i
s=gets.chomp.chars.map(&:ord)
l=0
while k>0&&l<n
	if (s[l]+l)%2>0
		s[l]^=3
		break if 0==k-=1
	end
	l+=1
	k-=1
end
s=s.rotate(l%n)
l%2>0&&s=s.map{|e|e^3}
s[0]^=(n*k)%2*3
puts s.map(&:chr)*''

Measured memory_bytes: 24388
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

  
signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  string s,t;
  cin >> s >> t;
  int ans = 0;
  REP(i, 3){
    if(s[i] == t[i]){
      ans++;
    }
  }

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

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

if N%2==0:
    for k in B:
        if k%2==0 or B[k]!=2:
            print(0)
            exit(0)
else:
    if B[0] != 1:
        print(0)
        exit(0)
    B[0] = 2
    for k in B:
        if k%2==1 or B[k]!=2:
            print(0)
            exit(0)

ans = 1
for k in range(N//2):
    ans *= 2
    ans %= 10**9+7
print(ans)

Measured memory_bytes: 14820
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		if(n<3){
			System.out.println(n);
			return;
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.add(2);
		for(int i=3; i<=n; i++){
			boolean b = true;
			for(int j=0; j<list.size(); j++){
				if(i % list.get(j) == 0){
					b = false;
					break;
				}
			}
			if(b){
				list.add(i);
			}
		}
		
		long[][] num = new long[n][list.size()];
		for(int i=1; i<=n; i++){
			int x = i;
			for(int j=0; j<list.size(); j++){
				while(x % list.get(j) == 0){
					num[i-1][j]++;
					x /= list.get(j);
				}
			}
		}
		long[] sum = new long[list.size()];
		for(int i=1; i<=n; i++){
			for(int j=0; j<list.size(); j++){
				sum[j] += num[i-1][j];
			}
		}
		long ans = 1;
		for(int i=0; i<list.size(); i++){
			if(sum[i] != 0){
				ans *= sum[i] + 1L;
			}
			if(ans >= 1000000007L){
				ans %= 1000000007L;
			}
		}
		System.out.println(ans);
	}

}

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

int main(){

  int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<long long int> A(X,0),B(Y,0),C(Z,0);
    for(int i=0;i<X;i++){
        cin>>A[i];
    }
    /*sort(A.begin(),A.end());
    reverse(A.begin(),A.end());*/
    for(int i=0;i<Y;i++){
        cin>>B[i];
    }
    /*sort(B.begin(),B.end());
    reverse(B.begin(),B.end());*/
    for(int i=0;i<Z;i++){
        cin>>C[i];
    }
    /*sort(C.begin(),C.end());
    reverse(C.begin(),C.end());*/
    vector<long long int> D(X*Y,0);
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            D[i*Y+j]=A[i]+B[j];
        }
    }
    sort(D.begin(),D.end());
    reverse(D.begin(),D.end());
    vector<long long int> E((min(X*Y,K))*Z,0);
    for(int i=0;i<min(X*Y,K);i++){
        for(int j=0;j<Z;j++){
            E[i*Z+j]=D[i]+C[j];
        }
    }
    sort(E.begin(),E.end());
    for(int i=0;i<K;i++){
        cout<<E[E.size()-1-i]<<endl;
    }
}


Measured memory_bytes: 31616
# encoding: utf-8
H, W = map(int, input().split())
a = [input() for i in range(H)]

a2 = []
for item in a:
    if item == "." * W: continue
    a2.append(item)

white = []
for j in range(W):
    for item in a2:
        if item[j] == "#": break
        else: continue
    else:
        white.append(j)

a3 = []
for item in a2:
    line = ""
    for j in range(W):
        if j in white: continue
        line += item[j]
    a3.append(line)

for item in a3: print(item)


Measured memory_bytes: 3064
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
#define reg register
#define int long long
using namespace std;
const int MaxN=100051;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
string s[MaxN];
char inp[21];
signed main(void)
{
	int n;rd(n);
	reg int len;
	reg int ans=0,cnt=1;
	for(int i=1;i<=n;++i)
	{
		s[i]="";
		cin>>inp;
		len=strlen(inp);
		sort(inp,inp+len);
		for(int j=0;j<len;++j)
			s[i]+=inp[j];
	}
	sort(s+1,s+n+1);
	for(int i=1;i<n;++i)
	{
		if(s[i]==s[i+1])
			++cnt;
		else
			ans+=cnt*(cnt-1)/2,cnt=1;
	}
	if(cnt)
		ans+=cnt*(cnt-1)/2;
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  if(k>(n-1)*(n-2)/2){
    cout<<-1<<endl;
  }
  else{
    int a=n*(n-1)/2-k;
    cout<<a<<endl;
    bool p=true;
    rep(i,1,n){
      rep(j,i+1,n+1){
        a--;
        cout<<i<<" "<<j<<endl;
        if(a==0){
          p=false;
          break;
        }
      }
      if(!p) break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,s,x;
	cin>>a>>b;
	if(a>=1&&a<=100&&b>=1&&b<=100)
	{
	s=a+b;
	if(s%2==0)
	x=s/2;
	else
	x=s/2+1;
	cout<<x;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}

// n の素因数を (素因数, 個数) のペアで列挙して返す。O(sqrt(N))
map<i64, int> getPrimeFactors(i64 n)
{
    map<i64, int> pf;
    for (i64 i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            pf[i] += 1;
            n /= i;
        }
    }
    if (n != 1) pf[n] = 1;
    return pf;
}

signed main()
{
    int N;
    scanf("%d", &N);

    auto pf = getPrimeFactors(N);

    printf("%d:", N);
    for (const auto &e : pf) {
        rep(i, 0, e.second) {
            printf(" %lld", e.first);
        }
    }

    puts("");

    return 0;
}



Measured memory_bytes: 3224
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    
    return 0;
}

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

int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    if((a*b)>(c*d))
    {
        printf("%d", a*b);
    }
    else
    {
        printf("%d", c*d);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int n;
	int d[110];
	cin >> n;
	for (int i = 0; i < n; i++)  cin >> d[i];

	sort(d, d + n);
	int min = d[0];
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (d[i] > min) {
			min = d[i];
			ans++;
		}
	}

	cout << ans << endl;
}

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

bool IsOneBit(long long bits, int i) {
	return (bits & (1ll << i)) > 0;
}
int main() {
	int N;
	const int M = 1000000007;
	cin >> N;
	vector<long long> A(N);
	long long AMax = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		AMax = max(A[i], AMax);
	}
	int digit = log2(AMax);
	long long ans = 0;
	for (int i = 0; i <= digit; i++) {
		long long zero = 0, one = 0;
		for (long long a : A) {
			if (IsOneBit(a, i))one++;
			else zero++;
		}
		long long k = (1ll << i) % M;
		k = k * one % M;
		k = k *zero % M;
		ans = (ans + k) % M;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	// aにできるまで最初からステップ，あとは最後のものを最後まで回す
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder str = new StringBuilder(br.readLine());
		long num = Integer.valueOf(br.readLine());
		br.close();
		int index = 0;
		int length = str.length();

		while (index < length - 1) {
//			if(num>26*length){
//				str = str.replaceAll("[a-z]", "a");
//				break;
//			}
			if (num >= counttoa(str.charAt(index))) {
				num = num - counttoa(str.charAt(index));
//				str = str.substring(0, index) + "a" + str.substring(index + 1);
				str.setCharAt(index, 'a');
			}
			index++;
		}

		// 最後の文字を変換
//		str = str.substring(0, length - 1) + stepChr(str.charAt(length - 1), num);
		str.setCharAt(length-1, stepChr(str.charAt(length-1),num));
		System.out.println(str);

	}

	private static char stepChr(char input, long num) {
		long realNum = num % 26;
		char result = input;
		for (int i = 0; i < realNum; i++) {
			result = nextChr(result);
		}
		return result;
	}

	private static char nextChr(char input) {
		if (input == 'z') {
			return 'a';
		} else
			return (char) ((int) input + 1);

	}

	private static int counttoa(char input) {
		if (input == 'a') {
			return 0;
		}
		return 26 - ((int) input - (int) 'a');
	}

}


Measured memory_bytes: 11476
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

string N;
ll ans;
ll dp[10][2][2][2][2];

bool ok;
int main() {
    cin>>N;
    ll keta=N.size();
    dp[0][0][0][0][0]=1;
    REP(i,0,keta){
        REP(seven,0,2){
            REP(five,0,2){
                REP(three,0,2){
                    REP(f,0,2) {
                        if(f){
                            dp[i + 1][true][five][three][1] += dp[i][seven][five][three][f];
                            dp[i + 1][seven][true][three][1] += dp[i][seven][five][three][f];
                            dp[i + 1][seven][five][true][1] += dp[i][seven][five][three][f];
                        }else{
                            if (N[i] > '7') {
                                dp[i + 1][true][five][three][1] += dp[i][seven][five][three][f];
                                dp[i + 1][seven][true][three][1] += dp[i][seven][five][three][f];
                                dp[i + 1][seven][five][true][1] += dp[i][seven][five][three][f];
                            } else if (N[i] == '7') {
                                dp[i + 1][true][five][three][f] += dp[i][seven][five][three][f];
                                dp[i + 1][seven][true][three][1] += dp[i][seven][five][three][f];
                                dp[i + 1][seven][five][true][1] += dp[i][seven][five][three][f];
                            }else if (N[i] > '5') {
                                dp[i + 1][seven][true][three][1] += dp[i][seven][five][three][f];
                                dp[i + 1][seven][five][true][1] += dp[i][seven][five][three][f];
                            } else if (N[i] == '5') {
                                dp[i + 1][seven][true][three][f] += dp[i][seven][five][three][f];
                                dp[i + 1][seven][five][true][1] += dp[i][seven][five][three][f];
                            } else if (N[i] > '3') {
                                dp[i + 1][seven][five][true][1] += dp[i][seven][five][three][f];
                            }else if (N[i] == '3') {
                                dp[i + 1][seven][five][true][f] += dp[i][seven][five][three][f];
                            }else{
                                dp[i + 1][seven][five][three][f] = 0;
                            }

                        }

                    }
                }
            }
        }
    }

    ans+=dp[keta][1][1][1][0]+=dp[keta][1][1][1][1];
    REP(i,3,keta){
        ans += pow(3, i) - 3 * pow(2, i)+3;
    }
    p(ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    string T1,T2;
    bool flag1 = false;
    bool flag2 = false;
    int Count = 0;
    int NowCount;
    for(int i = 0; i < N; i++){
        NowCount = 0;
        T1 = S.substr(0,i+1);
        T2 = S.substr(i+1,N-(i+1));
        for(char c = 'a'; c <= 'z'; c++){
            flag1 = false;
            flag2 = false;
            for(int j = 0; j < T1.size(); j++){
                if(T1[j] == c) flag1 = true;
            }
            for(int j = 0; j < T2.size(); j++){
                if(T2[j] == c) flag2 = true;
            }
            if(flag1&&flag2) NowCount++;
        }
        Count = max(Count,NowCount);
    }
    cout << Count << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
flag=0
cnt=1
for i in range(n-1):
    if flag==0:
        if a[i]<a[i+1]:
            flag=1
        elif a[i]>a[i+1]:
            flag=2
    elif flag==1:
        if a[i]>a[i+1]:
            flag=0
            cnt+=1
    else:
        if a[i]<a[i+1]:
            flag=0
            cnt+=1
print(cnt)


Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    std::string S;
    std::cin >> S;
    ll cnt=0;
    ll maxcnt=0;
    for (long long i = 0; i < S.length(); i++) {
        if(S[i]=='R') cnt++;
        if(S[i]=='S') {
            chmax(maxcnt,cnt);
            cnt=0;
        }
    }
    chmax(maxcnt,cnt);
    cout << maxcnt << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int i;
    int m=100000;
    for(i=0;i<n;i++){
        m=m*1.05;
        if(m%1000!=0)       m=(m/1000)*1000+1000;
    }
    cout<<m;
    cout<<endl;
}



Measured memory_bytes: 3084
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		
// 		Scanner sc= new Scanner(System.in);
// 		String s1 = sc.next();
// 		String s2 = sc.next();
// 		int dp[][]=new int[s1.length()][s2.length()];
// 		for(int i=0;i<s1.length;i++){
// 		    for(j=0;j<s2.lengthh;j++){
// 		        if(s1.charAt(i)==s2.charAt(j)) {
// 		            if(j==0){
// 		                dp[i][j]= 1;
// 		            }
// 		            else {
// 		               dp[i][j]= dp[i-1][j-1]+1; 
// 		            }
// 		        }
// 		        else{
// 		            if(j>0)
// 		                dp[i][j]=dp[i][j-1];
// 		        }
// 		    }
	//	}
	
	Scanner sc= new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int wt[] = new int[n];
		int val[] = new int[n];
		for(int i=0;i<n;i++){
		    wt[i] = sc.nextInt();
		    val[i]=sc.nextInt();
		}
		long dp[][]=new long[w+1][n];
		long maxv = Long.MIN_VALUE;
		for(int i=0;i<=w;i++){
		    for(int j=0;j<n;j++){
		        if (i==0){
		            dp[i][j]=0;
		        }
		        else {
		            if (j>0) {
		                dp[i][j] = dp[i][j-1];
		            }
		            if (i-wt[j]>=0){
		                if (i-wt[j]==0){
		                    if (j>0){
		                        dp[i][j]=Math.max(dp[i][j], dp[i-wt[j]][j-1]+val[j]); 
		                    }
		                  else {
		                      dp[i][j]=Math.max(dp[i][j], val[j]); 
		                  }
		                }
		                else {
		                    if (dp[i-wt[j]][j]>0){
		                        if (j>0){
		                        dp[i][j]=Math.max(dp[i][j], dp[i-wt[j]][j-1]+val[j]); 
		                    }
		                    else {
		                        dp[i][j]=Math.max(dp[i][j], val[j]);
		                    }
		                        
		                    }
		                }
		                
		            }
		        }
		    }
		    //System.out.print(dp[i][n-1]+" "+i);
		    //System.out.println();
		   maxv = Math.max(maxv, dp[i][n-1]);
		}
	    System.out.println(maxv);
		
	}
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    for (int i = 1; i < s.size(); ++i) {
        if(s[i]==s[i-1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;
 
int n, m, comp1, comp2, cnt;
vector<int> g[maxn];
bool vis[maxn];

ll C (int a)
{
	return 1ll * a * (a-1) / 2;
}

void dfs (int v)
{
	vis[v] = true;
	cnt ++;
	for (int i : g[v])
		if (!vis[i])
			dfs (i);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		g[--a].pb(--b); g[b].pb(a);
	}
	dfs (0);
	comp1 = cnt;
	cnt = 0;
	dfs (1);
	comp2 = cnt;
	if (comp1 < comp2)
		swap (comp1, comp2);
	comp1 += n - (comp1 + comp2);
	cout << C (comp1) + C (comp2) - m << endl;


	return 0;
}

Measured memory_bytes: 11264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int A=sc.nextInt();
		int P=sc.nextInt();
		int sum=A*3+P;
		pl(sum/2);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 22228
import java.util.*;

public class Main {

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

        int x = -1;

        for(int i = 1 ; i <= 10000 ; i++){
            if(8*i/100 == a && i/10 == b){
                x = i;
                break;
            }
        }

        System.out.println(x);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int a, p;
  cin >> a >> p;
  p += a * 3;
  int ans = p / 2;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
unittest
{
	assert( [ "2", "1 2 1 2 2 1" ].solve == 2 );
	assert( [ "3", "1 1 2 2 3 3 3 2 1" ].solve == 1 );
	assert( [ "3", "1 1 2 2 2 3 3 3 1" ].solve == 3 );
}



import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	as[] -= 1;
	
	// インラインDP
	// dp[ (iターン目) ][ 残したカード1枚目の数字 ][ 残したカード2枚目の数字 ] = 最大得点
	auto dp = new long[][]( n, n );
	foreach( ref dpp; dp ) dpp[] = long.min;					// -2000未満にしておけば絶対0以上にならないので無視できる
	auto z = 0L;												// 全体加算値
	auto mm = 0L;												// 全体最大値
	auto ms = new long[ n ];									// 部分最大値
	ms[] = long.min;
	auto queue = DList!( Tuple!( long, long, long ) )();		// 更新キュー
	
	// 最初のカード2枚を処理
	dp[ as[ 0 ] ][ as[ 1 ] ] = 0;
	dp[ as[ 1 ] ][ as[ 0 ] ] = 0;
	ms[ as[ 0 ] ] = 0;
	ms[ as[ 1 ] ] = 0;
	as.popFrontN( 2 );
	
	// 途中のカードを3枚ずつ処理
	foreach( i; 0L .. n - 1 )
	{
		if( as[ 0 ] == as[ 1 ] && as[ 0 ] == as[ 2 ] )
		{
			// 次の3枚が全て同値の場合
			// 全てのx,yについて dp[ i+1 ][ x ][ y ] = dp[ i ][ x ][ y ] +1 が最適になるので、全体加算値に+1する
			z++;
		}
		else
		{
			foreach( j; 0 .. 3 )
			{
				auto a = as[ j ];
				auto b = as[ 0 + ( j <= 0 ) ];
				auto c = as[ 1 + ( j <= 1 ) ];
				
				// 前ターンのx,yを両方を残す場合
				// dp[ i+1 ][ x ][ y ] = dp[ i ][ x ][ y ] になるので、処理不要
				
				// 前ターンのx,yの片方を残す場合
				// dp[ i+1 ][ x ][ a or b or c ] = dp[ i ][ x ][ ? ].reduce!max になるので、部分最大値を使って更新する
				// また、捨て札y,b,cが全て同値の場合は+1する
				foreach( x; 0L .. n )
				{
					auto v = ms[ x ];
					if( b == c ) v = max( v, dp[ x ][ b ] + 1 );
					queue.insertBack( tuple( x, a, v ) );
				}
				
				// 前ターンのx,yのどちらも残さない場合
				// dp[ i + 1 ][ a or b or c ][ a or b or c ] = dp[ i + 1 ][ ? ][ ? ].reduce!max になるので、全体最大値を使って更新する
				// また、捨て札x,y,c or x,y,bが全て同値の場合は+1する
				queue.insertBack( tuple( a, b, max( mm, dp[ c ][ c ] + 1 ) ) );
				queue.insertBack( tuple( a, c, max( mm, dp[ b ][ b ] + 1 ) ) );
			}
		}
		
		// DPテーブルと最大値を更新
		while( !queue.empty )
		{
			auto x = queue.front[ 0 ];
			auto y = queue.front[ 1 ];
			auto v = queue.front[ 2 ];
			queue.removeFront;
			
			dp[ x ][ y ] = max( dp[ x ][ y ], v );
			dp[ y ][ x ] = max( dp[ y ][ x ], v );
			ms[ x ] = max( ms[ x ], v );
			ms[ y ] = max( ms[ y ], v );
			mm = max( mm, v );
		}
		as.popFrontN( 3 );
	}
	
	// 最後のカード1枚を処理
	auto ans = 0L;
	foreach( x, ref dpp; dp )
	{
		foreach( y, ref dppp; dpp )
		{
			ans = max( ans, dppp + ( x == y && y == as[ 0 ] ) );
		}
	}
	ans += z;
	return ans;
}


Measured memory_bytes: 36184
#include <stdio.h>
 
#define QSIZE 2000002
 
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)
 
typedef struct { int t; } QUE;
QUE que[QSIZE+5];
int qsize;
 
void max_heapify(int i)
{
    int l, r, max;
    QUE qt;
    l = LEFT(i), r = RIGHT(i);
    if (l < qsize && que[l].t > que[i].t) max = l; else max = i;
    if (r < qsize && que[r].t > que[max].t) max = r;
    if (max != i) {
        qt = que[i], que[i] = que[max], que[max] = qt;
        max_heapify(max);
    }
}
 
int deq()
{
    int r = que[0].t;
    que[0] = que[--qsize];
    max_heapify(0);
    return r;
}
 
void enq(int t)
{
    int i, max;
    QUE qt;
 
    i = qsize++;
    que[i].t = t;
    while (i > 0 && que[max = PARENT(i)].t < que[i].t) {
        qt = que[i]; que[i] = que[max], que[max] = qt;
        i = max;
    }
}
 
// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
char buf[20];
void mypr(int n)
{
    int i = 0;
    if (n == 0) buf[i++] = '0';
    else while (n) buf[i++] = n%10 + '0', n/=10;
    while (i) pc(buf[--i]);
    pc('\n');
}
             
int main()
{
    int k;
 
    qsize = 0;
    while (1) {
        if (gc() == 'e') {
            if (gc() == 'n') break;
            k = 6; while (k--) gc();
            mypr(deq());
        } else {
            k = 6; while (k--) gc();
            enq(in());
        }
    }
    return 0;
}



Measured memory_bytes: 5448
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

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



signed main() {

	ll n = 0;

	ll a, b, x, y;
	cin >> a >> b;
	if (a < b) {
		x = b;
		y = a;
	}
	else {
		x = a;
		y = b;
	}
	ll r = x % y;

	while(r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	
	cout << (a / y) * b;
}

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

void OutputHeap(std::vector<int>& Heap)
{
	int Count = Heap.size();
	for(int i = 1; i <= Count; ++i){
		std::cout << "node "  << i << ": "
		          << "key = " << Heap[i - 1] << ", ";
		if(i > 1){
			std::cout << "parent key = " << Heap[i / 2 - 1] << ", ";
		}
		if(2 * i <= Count){
			std::cout << "left key = " << Heap[2 * i - 1] << ", ";
		}
		if(2 * i + 1 <= Count){
			std::cout << "right key = " << Heap[2 * i] << ", ";
		}
		std::cout << std::endl;
	}
}

int main()
{
	int Count = 0;
	std::cin >> Count;
	std::vector<int> Heap(Count);
	for(int i = 0; i < Count; ++i){
		std::cin >> Heap[i];
	}
	
	OutputHeap(Heap);
	
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const int INF=1000;

int main(){
  string s;
  ll n;
  cin>>n;
  ll Nr,Ng,Nb;
  ll sum1,sum2;
  cin>>s;
  Nr=count(s.begin(),s.end(),'R');
  Ng=count(s.begin(),s.end(),'G');
  Nb=count(s.begin(),s.end(),'B');
  sum1=Nr*Ng*Nb;
  sum2=0;
  rep(i,n){
    for(int j=i+1; j<=int((n+i)/2); ++j){
      //cout <<s[i]<<s[j]<<endl;
      string test= {s[i],s[j],s[2*j-i]};
      sort(test.begin(),test.end());
      //cout <<test<<endl;
      if (test=="BGR"){
        sum2++;
      }
    }
  }
  cout <<sum1-sum2<<endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

        if (n < 1000) {
            System.out.println("ABC");
        } else {
            System.out.println("ABD");
        }
    }
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    REP(i, h) REP(j, w) cin >> a[i][j];

    set<int> hr;
    set<int> wr;
    REP(i, h) {
        bool b = true;
        REP(j, w) {
            if (a[i][j] == '#') {
                b = false;
                break;
            }
        }
        if (b) hr.insert(i);
    }
    REP(j, w) {
        bool b = true;
        REP(i, h) {
            if (a[i][j] == '#') {
                b = false;
                break;
            }
        }
        if (b) wr.insert(j);
    }

    REP(i, h) {
        if (hr.count(i)) continue;
        REP(j, w) {
            if (wr.count(j)) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
}

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

using namespace std;

int odp[1007];

int main()
{
    long long int n, i=0;
    cin >> n;
    while(n){
        odp[i]=(n+25)%26;
        n=(n-1)/26;
        i++;
    }
    for(i--; i>=0; i--){
        cout << (char)('a'+odp[i]);
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, k = MI()
    S = [1] * n
    for i in range(k):
        d = II()
        A = LI1()
        for a in A:
            S[a] = 0
    # print(S)
    print(sum(S))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9220
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    for (int i = 1; i <= 9; ++i)
    {
        int num = 100*i + 10 * i + i;
        if (n <= num)
        {
            cout << num << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256